Share Pastebin
Guest
Public paste!

kaiser / für CYSTATS

By: a guest | Mar 5th, 2010 | Syntax: PHP | Size: 14.69 KB | Hits: 175 | Expires: Never
Copy text to clipboard
  1. <?php
  2. /*
  3. Template Name: current_user_data
  4. */
  5.     get_header();
  6.  
  7.     global $current_user;
  8.     global $wpdb;
  9.  
  10.     if ( is_user_logged_in() ) {
  11.  
  12.     /* Funktioniert, aber unnötig
  13.     $user_id = $current_user->ID;
  14.     $user = get_userdata($user_id);
  15.     */
  16.     /* echo "CUR_USER: " . var_dump($current_user) . "<br />"; */
  17.     /* echo "USER: " . var_dump($user) . "<br />"; */
  18.  
  19.     // user_meta arrays:
  20.     $metaboxhidden_dashboard = $current_user->metaboxhidden_dashboard;
  21.     $capabilities = $current_user->{ $wpdb->prefix . 'capabilities' };
  22.     $closedpostboxes_page = $current_user->closedpostboxes_page;
  23.     $metaboxhidden_page = $current_user->metaboxhidden_page;
  24.     $autosave_draft_ids = $current_user->{ $wpdb->prefix . 'autosave_draft_ids' };
  25.     $closedpostboxes_post = $current_user->closedpostboxes_post;
  26.     $metaboxhidden_post = $current_user->metaboxhidden_post;
  27.     $metaboxorder_dashboard = $current_user->{ $wpdb->prefix . 'metaboxorder_dashboard' };
  28.  
  29.     echo "<div class='container'>";
  30.  
  31.     echo "<div class='span-24 last' id='current-user-data'>";
  32.         $user = new WP_User($ID);
  33.         $current_user_test = get_current_user();
  34.         /* echo "<p>wp_capabilities: " . print_r(array_keys($current_user_test->capabilities)) . "</p>"; */
  35.  
  36.     echo "<table rules='rows'>";
  37.  
  38.     $cur_user_roles = $current_user->roles;
  39.         foreach($cur_user_roles as $cur_user_roles_value) {
  40.             $role_to_compare = $cur_user_roles_value;
  41.         }
  42.     echo "<caption>Data of the currently logged in user with the ";
  43.         echo "<i>Role: ";
  44.             if($role_to_compare == 'administrator') {
  45.                 echo "Administrator ";
  46.             } elseif($role_to_compare == 'editor') {
  47.                 echo "Editor ";
  48.             } elseif($role_to_compare == 'author') {
  49.                 echo "Author ";
  50.             } elseif($role_to_compare == 'contributor') {
  51.                 echo "Contributer ";
  52.             } elseif($role_to_compare == 'subscriber') {
  53.                 echo "Subscriber ";
  54.             } else {
  55.                 echo "<i>Att.: user got no actual role in the system</i> ";
  56.             }
  57.         echo "</i>and the <i>Name: ";
  58.         if(!empty($current_user->user_firstname) && !empty($current_user->user_lastname)) {
  59.             echo $current_user->user_firstname;
  60.             echo " ";
  61.             echo $current_user->user_lastname;
  62.             echo " ";
  63.         }
  64.         echo "</i> - <i>Login Name(ID): ";
  65.         echo $current_user->user_login;
  66.         echo "(";
  67.         echo $current_user->ID;
  68.         echo ")</i>";
  69.     echo "</caption>";
  70.  
  71.     echo "<thead>";
  72.         echo "<th>What is?</th>";
  73.         echo "<th>code</th>";
  74.         echo "<th>Output</th>";
  75.     echo "</thead>";
  76.  
  77.     echo "<tbody>";
  78.         echo "<tr>";
  79.             echo "<td>ID: </td>" . "<td>ID</td>" . "<td>";
  80.                 if(!empty($current_user->ID)) { echo $current_user->ID; } else { echo "<i>EMPTY</i>"; }
  81.             echo "</td>";
  82.         echo "</tr>";
  83.         echo "<tr>";
  84.             echo "<td>id <i>depr.</i>: </td>" . "<td>id</td>" . "<td>";
  85.                 if(!empty($current_user->id)) { echo $current_user->id; } else { echo "<i>EMPTY</i>"; }
  86.             echo "</td>"; // depracated
  87.         echo "</tr>";
  88.         echo "<tr>";
  89.             echo "<td>Login: </td>" . "<td>user_login</td>" . "<td>";
  90.                 if(!empty($current_user->user_login)) { echo $current_user->user_login; } else { echo "<i>EMPTY</i>"; }
  91.             echo "</td>";
  92.         echo "</tr>";
  93.         echo "<tr>";
  94.             echo "<td>First Name: </td>" . "<td>user_firstname</td>" . "<td>";
  95.                 if(!empty($current_user->user_firstname)) { echo $current_user->user_firstname; } else { echo "<i>EMPTY</i>"; }
  96.             echo "</td>";
  97.         echo "</tr>";
  98.         echo "<tr>";
  99.             echo "<td>Last Name: </td>" . "<td>user_lastname</td>" . "<td>";
  100.                 if(!empty($current_user->user_lastname)) { echo $current_user->user_lastname; } else { echo "<i>EMPTY</i>"; }
  101.             echo "</td>";
  102.         echo "</tr>";
  103.         echo "<tr>";
  104.             echo "<td>Display Name: </td>" . "<td>display_name</td>" . "<td>";
  105.                 if(!empty($current_user->display_name)) { echo $current_user->display_name; } else { echo "<i>EMPTY</i>"; }
  106.             echo "</td>";
  107.         echo "</tr>";
  108.         echo "<tr>";
  109.             echo "<td>Nice Name: </td>" . "<td>user_nicename</td>" . "<td>";
  110.                 if(!empty($current_user->user_nicename)) { echo $current_user->user_nicename; } else { echo "<i>EMPTY</i>"; }
  111.             echo "</td>";
  112.         echo "</tr>";
  113.         echo "<tr>";
  114.             echo "<td>Nick Name: </td>" . "<td>nickname</td>" . "<td>";
  115.                 if(!empty($current_user->nickname)) { echo $current_user->nickname; } else { echo "<i>EMPTY</i>"; }
  116.             echo "</td>";
  117.         echo "</tr>";
  118.         echo "<tr>";
  119.             echo "<td>Hidden Elements on Dashboard: </td>" . "<td>metaboxhidden_dashboard</td>" . "<td>";
  120.                 if(!empty($metaboxhidden_dashboard)) {
  121.                     foreach($metaboxhidden_dashboard as $metaboxhidden_dashboard_value) {
  122.                         echo $metaboxhidden_dashboard_value . ", ";
  123.                     }
  124.                 } else { echo "<i>EMPTY</i>"; }
  125.             echo "</td>";
  126.         echo "</tr>";
  127.         echo "<tr>";
  128.             echo "<td>Register Date: </td>" . "<td>user_registered</td>" . "<td>";
  129.                 if(!empty($current_user->user_registered)) { echo $current_user->user_registered; } else { echo "<i>EMPTY</i>"; }
  130.             echo "</td>";
  131.         echo "</tr>";
  132.         /*
  133.         echo "<tr>";
  134.             echo "<td>Pass(md5)): </td>" . "<td>user_pass</td>" . "<td>";
  135.                 if(!empty($current_user->user_pass)) { echo $current_user->user_pass; } else { echo "<i>EMPTY</i>"; }
  136.             echo "</td>";
  137.         echo "</tr>";
  138.         */
  139.         echo "<tr>";
  140.             echo "<td>Activation Key: </td>" . "<td>user_activation_key</td>" . "<td>";
  141.                 if(!empty($current_user->user_activation_key)) { echo $current_user->user_activation_key; } else { echo "<i>EMPTY</i>"; }
  142.             echo "</td>";
  143.         echo "</tr>";
  144.         echo "<tr>";
  145.             echo "<td>Status <i>not used</i>: </td>" . "<td>user_status</td>" . "<td>";
  146.                 if(!empty($current_user->user_status)) { echo $current_user->user_status; } else { echo "<i>EMPTY</i>"; }
  147.             echo "</td>";
  148.         echo "</tr>";
  149.         echo "<tr>";
  150.             echo "<td>Rich Editing allowed: </td>" . "<td>rich_editing</td>" . "<td>";
  151.                 if(!empty($current_user->rich_editing)) {
  152.                     if($current_user->rich_editing == 1) { echo "Allowed"; } else { echo "Forbidden"; }
  153.                 } else { echo "<i>EMPTY</i>"; }
  154.             echo "</td>";
  155.         echo "</tr>";
  156.         echo "<tr>";
  157.             echo "<td>Comment Shortcut: </td>" . "<td>comment_shortcuts</td>" . "<td>";
  158.                 if(!empty($current_user->comment_shortcuts)) {
  159.                     if($current_user->comment_shortcuts == 1) { echo "Allowed"; } else { echo "Forbidden"; };
  160.                 } else { echo "<i>EMPTY</i>"; }
  161.             echo "</td>";
  162.         echo "</tr>";
  163.         echo "<tr>";
  164.             echo "<td>Admin Color Scheme: </td>" . "<td>admin_color</td>" . "<td>";
  165.                 if(!empty($current_user->admin_color)) { echo $current_user->admin_color; } else { echo "<i>EMPTY</i>"; }
  166.             echo "</td>";
  167.         echo "</tr>";
  168.         echo "<tr>";
  169.             echo "<td>Capabilities: </td>" . "<td>$wpdb->prefix capabilities</td>" . "<td>";
  170.                 if(!empty($capabilities)) {
  171.                     foreach($capabilities as $capabilities_value) {
  172.                         echo $capabilities_value . "<br />";
  173.                     }
  174.                 } else { echo "<i>EMPTY</i>"; }
  175.             echo "</td>";
  176.         echo "</tr>";echo "<tr>";
  177.             echo "<td>Capabilities: </td>" . "<td>$wpdb->prefix capabilities</td>" . "<td>";
  178.                 if(!empty($current_user->capabilities)) {
  179.                     print_r($current_user->capabilities);
  180.                 } else { echo "<i>EMPTY</i>"; }
  181.             echo "</td>";
  182.         echo "</tr>";
  183.         echo "<tr>";
  184.             echo "<td>User Settings: </td>" . "<td>$wpdb->prefix usersettings</td>" . "<td>";
  185.                 $user_settings = $current_user->{$wpdb->prefix . 'usersettings'};
  186.                 if(!empty($user_settings)) { echo $user_settings; } else { echo "<i>EMPTY</i>"; }
  187.             echo "</td>";
  188.         echo "</tr>";
  189.         echo "<tr>";
  190.             echo "<td>Time of User Settings: </td>" . "<td>$wpdb->prefix usersettingstime</td>" . "<td>";
  191.                 $user_settingstime = $current_user->{$wpdb->prefix . 'usersettingstime'};
  192.                 if(!empty($user_settingstime)) { echo $user_settingstime; } else { echo "<i>EMPTY</i>"; }
  193.             echo "</td>";
  194.         echo "</tr>";
  195.         echo "<tr>";
  196.             echo "<td>Closed Boxes @Pages: </td>" . "<td>closedpostboxes_page</td>" . "<td>";
  197.                 if(!empty($closedpostboxes_page)) {
  198.                     foreach($closedpostboxes_page as $closedpostboxes_page_value) {
  199.                         echo $closedpostboxes_page_value . ", ";
  200.                     }
  201.                 } else { echo "<i>EMPTY</i>"; }
  202.             echo "</td>";
  203.         echo "</tr>";
  204.         echo "<tr>";
  205.             echo "<td>Meta Boxen hidden @Page(?): </td>" . "<td>metaboxhidden_page</td>" . "<td>";
  206.                 if(!empty($metaboxhidden_page)) {
  207.                     foreach($metaboxhidden_page as $metaboxhidden_page_value) {
  208.                         echo $metaboxhidden_page_value . "<br />";
  209.                     }
  210.                 } else { echo "<i>EMPTY</i>"; }
  211.             echo "</td>";
  212.         echo "</tr>";
  213.         echo "<tr>";
  214.             echo "<td>Autosave of Drafts(IDs): </td>" . "<td>$wpdb->prefix autosave_draft_ids</td>" . "<td>";
  215.                 if(!empty($autosave_draft_ids)) {
  216.                     foreach($autosave_draft_ids as $autosave_draft_ids_value) {
  217.                         echo $autosave_draft_ids_value . " - ";
  218.                     }
  219.                 } else { echo "<i>EMPTY</i>"; }
  220.             echo "</td>";
  221.         echo "</tr>";
  222.         echo "<tr>";
  223.             echo "<td>Closed Boxes @Posts: </td>" . "<td>closedpostboxes_post</td>" . "<td>";
  224.                 if(!empty($closedpostboxes_post)) {
  225.                     foreach($closedpostboxes_post as $closedpostboxes_post_value) {
  226.                         echo $closedpostboxes_post_value . ", ";
  227.                     }
  228.                 } else { echo "<i>EMPTY</i>"; }
  229.             echo "</td>";
  230.         echo "</tr>";
  231.         echo "<tr>";
  232.             echo "<td>Meta Boxen hidden @Post(?): </td>" . "<td>metaboxhidden_post</td>" . "<td>";
  233.                 if(!empty($metaboxhidden_post)) {
  234.                     foreach($metaboxhidden_post as $metaboxhidden_post_value) {
  235.                         echo $metaboxhidden_post_value . "<br />";
  236.                     }
  237.                 } else { echo "<i>EMPTY</i>"; }
  238.             echo "</td>";
  239.         echo "</tr>";
  240.         echo "<tr>";
  241.             echo "<td>Metabox-Order @Dashboard: </td>" . "<td>$wpdb->prefix metaboxorder_dashboard</td>" . "<td>";
  242.                 if(!empty($metaboxorder_dashboard)) {
  243.                     foreach($metaboxorder_dashboard as $metaboxorder_dashboard_value) {
  244.                         echo $metaboxorder_dashboard_value . "<br />";
  245.                     }
  246.                 } else { echo "<i>EMPTY</i>"; }
  247.             echo "</td>";
  248.         echo "</tr>";
  249.         echo "<tr>";
  250.             echo "<td>Screen Layout @Dashboard: </td>" . "<td>screen_layout_dashboard</td>" . "<td>";
  251.                 if(!empty($current_user->screen_layout_dashboard)) { echo $current_user->screen_layout_dashboard; } else { echo "<i>EMPTY</i>"; }
  252.             echo "</td>";
  253.         echo "</tr>";
  254.         echo "<tr>";
  255.             echo "<td>User-Level <i>depr.</i>: </td>" . "<td>$wpdb->prefix user_level</td>" . "<td>";
  256.                 $user_level_nr = $current_user->{$wpdb->prefix . 'user_level'};
  257.                 if(!empty($user_level_nr)) { echo $user_level_nr; } else { echo "<i>EMPTY</i>"; }
  258.             echo "</td>"; // depracated
  259.         echo "</tr>";
  260.         echo "<tr>";
  261.             echo "<td>user_level <i>depr.</i>: </td>" . "<td>user_level</td>" . "<td>";
  262.                 if(!empty($current_user->user_level)) { echo $current_user->user_level; } else { echo "<i>EMPTY</i>"; }
  263.             echo "</td>"; // depracated
  264.         echo "</tr>";
  265.         echo "<tr>";
  266.             echo "<td>Roles: </td>" . "<td>roles</td>" . "<td>";
  267.                 $cur_user_roles = $current_user->roles;
  268.                 if(!empty($cur_user_roles)) {
  269.                     foreach($cur_user_roles as $cur_user_roles_value) {
  270.                         echo $cur_user_roles_value . "<br />";
  271.                     }
  272.                 } else { echo "<i>EMPTY</i>"; }
  273.             echo "</td>";
  274.         echo "</tr>";
  275.         echo "<tr>";
  276.             echo "<td>Capabilities Key: </td>" . "<td>cap_key</td>" . "<td>";
  277.                 if(!empty($current_user->cap_key)) { echo $current_user->cap_key; } else { echo "<i>EMPTY</i>"; }
  278.             echo "</td>";
  279.         echo "</tr>";
  280.         echo "<tr>";
  281.             echo "<td>All Capabilities: </td>" . "<td>allcaps</td>" . "<td>";
  282.                 $cur_user_allcaps = $current_user->allcaps;
  283.                 if(!empty($cur_user_allcaps)) {
  284.                     foreach($cur_user_allcaps as $cur_user_allcaps_value) {
  285.                         if($cur_user_allcaps_value == 1) {
  286.                             echo "Yes, ";
  287.                         } elseif($cur_user_allcaps_value == 0) {
  288.                             echo "No, ";
  289.                         }
  290.                     }
  291.                 } else { echo "<i>EMPTY</i>"; }
  292.             echo "</td>";
  293.         echo "</tr>";
  294.         echo "<tr>";
  295.             echo "<td>Capabilities: </td>" . "<td>caps</td>" . "<td>";
  296.                 $cur_user_caps = $current_user->caps;
  297.                 if(!empty($cur_user_caps)) {
  298.                     foreach($cur_user_caps as $cur_user_caps_value) {
  299.                         echo $cur_user_caps_value;
  300.                     }
  301.                 } else { echo "<i>EMPTY</i>"; }
  302.             echo "</td>";
  303.         echo "</tr>";
  304.     echo "</tbody>";
  305.  
  306.     echo "<tfoot>";
  307.         echo "<th>What is?</th>";
  308.         echo "<th>code</th>";
  309.         echo "<th>Output</th>";
  310.     echo "</tfoot>";
  311.  
  312.     echo "</table>";
  313.  
  314.     echo "</div>";
  315.     echo "</div>";
  316.  
  317.     } else {
  318.         echo "<div class='container'>";
  319.             echo "<div class='span-24 last'>";
  320.                 echo "<p>You are not allowes to view this page.</p>";
  321.             echo "</div>";
  322.         echo "</div>";
  323.     }
  324. ?>