{"id":2481,"date":"2015-06-23T05:57:52","date_gmt":"2015-06-23T05:57:52","guid":{"rendered":"http:\/\/musilda.cz\/?p=2481"},"modified":"2015-06-23T05:57:52","modified_gmt":"2015-06-23T05:57:52","slug":"zobrazeni-nejnovejsich-uzivatelu-na-nastence","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/zobrazeni-nejnovejsich-uzivatelu-na-nastence\/","title":{"rendered":"Zobrazen\u00ed nejnov\u011bj\u0161\u00edch u\u017eivatel\u016f na n\u00e1st\u011bnce WordPressu"},"content":{"rendered":"\n

V p\u0159\u00edpad\u011b, \u017ee umo\u017e\u0148ujete u\u017eivatel\u016fm registraci do WordPressu a chcete m\u00edt p\u0159ehled o tom, kdo se aktu\u00e1ln\u011b registroval, bude se v\u00e1m hodit dne\u0161n\u00ed snippet.<\/p>\n\n\n\n

Nejprve v\u00fdsledek:<\/p>\n\n\n

\n
\"Nov\u00ed<\/a>
Nov\u00ed u\u017eivatel\u00e9 na n\u00e1st\u011bnce WordPressu<\/figcaption><\/figure><\/div>\n\n\n

P\u0159esn\u011b takov\u00fd nov\u00fd box uvid\u00edte po pou\u017eit\u00ed n\u00e1sleduj\u00edc\u00edho k\u00f3du, kter\u00fd vlo\u017ete na konec souboru functions.php (k souboru se dostanete p\u0159es Vzhled > Editor souboru \u0161ablony<\/strong>). Z\u00e1rove\u0148 zkontrolujte, \u017ee pou\u017e\u00edv\u00e1te child theme<\/strong><\/a>, jinak by se ve\u0161ker\u00e9 zm\u011bny po aktualizaci \u0161ablony smazaly!<\/p>\n\n\n\n

K\u00f3d:<\/p>\n\n\n\n

add_action('wp_dashboard_setup', 'custom_dashboard_widgets');\n\nfunction custom_dashboard_widgets() {\n  global $wp_meta_boxes;\n  wp_add_dashboard_widget('custom_user_widget', __('Nov\u00ed u\u017eivatel\u00e9','textdomain'), 'custom_dashboard_user');\n}\n\/**\n * Dashboard widget function\n *\n *\/\nfunction custom_dashboard_user() {\n\n    global $wpdb;\n    $usernames = $wpdb->get_results(\"SELECT * FROM $wpdb->users ORDER BY ID DESC LIMIT 6\");\n\n?>\n<table style=\"width:100%;\">\n  <tr>\n    <td><b><?php _e('Datum registrace','texdomain'); ?><\/b><\/td>\n    <td><b><?php _e('Jm\u00e9no u\u017eivatele','texdomain'); ?><\/b><\/td>\n    <td><b><?php _e('U\u017eivatelsk\u00e1 role','texdomain'); ?><\/b><\/td>\n  <\/tr>\n  <?php\n  foreach ($usernames as $username) {\n    $userid = $username->ID ;\n  ?>\n  <tr>\n    <td>\n      <?php  $reg_date =  $username->user_registered ;  echo date('j m Y , h:i:s', strtotime($reg_date));?>\n    <\/td>\n    <td>\n      <a href=\"<?php echo get_edit_user_link($userid); ?>\"><?php echo $username->user_nicename ; ?><\/a>\n    <\/td>\n    <td>\n      <?php $user_info = get_userdata($userid);  echo  implode(', ', $user_info->roles)?>\n    <\/td>\n  <\/tr>\n  <?php } ?>\n<\/table>\n<?php\n}<\/code><\/pre>\n\n\n\n
\"\"<\/a><\/figure>\n\n\n\n

Jak m\u016f\u017eete vid\u011bt, po\u010det zobrazen\u00fdch u\u017eivatel\u016f je nastaven na \u0161est, ale hodnotu si m\u016f\u017eete p\u0159epsat, jak budete pot\u0159ebovat.<\/p>\n","protected":false},"excerpt":{"rendered":"

V p\u0159\u00edpad\u011b, \u017ee umo\u017e\u0148ujete u\u017eivatel\u016fm registraci do WordPressu a chcete m\u00edt p\u0159ehled o tom, kdo se aktu\u00e1ln\u011b registroval, bude se v\u00e1m hodit dne\u0161n\u00ed snippet. Nejprve v\u00fdsledek: P\u0159esn\u011b takov\u00fd nov\u00fd box uvid\u00edte po pou\u017eit\u00ed n\u00e1sleduj\u00edc\u00edho k\u00f3du, kter\u00fd vlo\u017ete na konec souboru functions.php (k souboru se dostanete p\u0159es Vzhled > Editor souboru \u0161ablony). Z\u00e1rove\u0148 zkontrolujte, \u017ee pou\u017e\u00edv\u00e1te child<\/p>\n","protected":false},"author":1,"featured_media":9642,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,19,30],"tags":[355,460],"class_list":["post-2481","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-navody","category-snippety","category-wordpress","tag-snippet","tag-wordpress-2"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2481"}],"collection":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/comments?post=2481"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2481\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/9642"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}