2013-03-25 3 views
0

Я пытаюсь получить первое имя пользователя в Wordpress, используя следующий код:Wordpress Получить Имя и фамилия

global $current_user; 
get_currentuserinfo(); 
var_dump($current_user); 

... и мой выход в конце поста.

Согласно the documentation, я должен иметь возможность получать имя и фамилию пользователя. Однако имитировать их пример было бы бесплодным, так как ни user_firstname, ни user_lastname не отображаются в этой переменной дампе

Любые идеи о том, почему нет? Я использую Wordpress 3.5.1, и моя учетная запись WP имеет первое и последнее имя.

Спасибо за ваше время.

Выход:

object(WP_User)[113] 
    public 'data' => 
    object(stdClass)[115] 
     public 'ID' => string '1' (length=1) 
     public 'user_login' => string 'stuff' (length=16) 
     public 'user_pass' => string 'stuff' (length=34) 
     public 'user_nicename' => string 'stuff' (length=15) 
     public 'user_email' => string 'stuff' (length=16) 
     public 'user_url' => string '' (length=0) 
     public 'user_registered' => string '2013-03-24 16:54:43' (length=19) 
     public 'user_activation_key' => string '' (length=0) 
     public 'user_status' => string '0' (length=1) 
     public 'display_name' => string 'stuff' (length=12) 
    public 'ID' => int 1 
    public 'caps' => 
    array (size=1) 
     'administrator' => boolean true 
    public 'cap_key' => string 'wp_capabilities' (length=15) 
    public 'roles' => 
    array (size=1) 
     0 => string 'administrator' (length=13) 
    public 'allcaps' => 
    array (size=63) 
     'switch_themes' => boolean true 
     'edit_themes' => boolean true 
     'activate_plugins' => boolean true 
     'edit_plugins' => boolean true 
     'edit_users' => boolean true 
     'edit_files' => boolean true 
     'manage_options' => boolean true 
     'moderate_comments' => boolean true 
     'manage_categories' => boolean true 
     'manage_links' => boolean true 
     'upload_files' => boolean true 
     'import' => boolean true 
     'unfiltered_html' => boolean true 
     'edit_posts' => boolean true 
     'edit_others_posts' => boolean true 
     'edit_published_posts' => boolean true 
     'publish_posts' => boolean true 
     'edit_pages' => boolean true 
     'read' => boolean true 
     'level_10' => boolean true 
     'level_9' => boolean true 
     'level_8' => boolean true 
     'level_7' => boolean true 
     'level_6' => boolean true 
     'level_5' => boolean true 
     'level_4' => boolean true 
     'level_3' => boolean true 
     'level_2' => boolean true 
     'level_1' => boolean true 
     'level_0' => boolean true 
     'edit_others_pages' => boolean true 
     'edit_published_pages' => boolean true 
     'publish_pages' => boolean true 
     'delete_pages' => boolean true 
     'delete_others_pages' => boolean true 
     'delete_published_pages' => boolean true 
     'delete_posts' => boolean true 
     'delete_others_posts' => boolean true 
     'delete_published_posts' => boolean true 
     'delete_private_posts' => boolean true 
     'edit_private_posts' => boolean true 
     'read_private_posts' => boolean true 
     'delete_private_pages' => boolean true 
     'edit_private_pages' => boolean true 
     'read_private_pages' => boolean true 
     'delete_users' => boolean true 
     'create_users' => boolean true 
     'unfiltered_upload' => boolean true 
     'edit_dashboard' => boolean true 
     'update_plugins' => boolean true 
     'delete_plugins' => boolean true 
     'install_plugins' => boolean true 
     'update_themes' => boolean true 
     'install_themes' => boolean true 
     'update_core' => boolean true 
     'list_users' => boolean true 
     'remove_users' => boolean true 
     'add_users' => boolean true 
     'promote_users' => boolean true 
     'edit_theme_options' => boolean true 
     'delete_themes' => boolean true 
     'export' => boolean true 
     'administrator' => boolean true 
    public 'filter' => null 
+0

Вы вошли в систему? Я думаю, вы знаете это, но вам нужно войти в систему, чтобы он работал. – AndyWarren

+0

@ AndyWarren Yep. Он получает всю мою информацию, кроме имени/фамилии. –

ответ

0

Вау! Сейчас это случайная работа.

  1. Установите первое и последнее имя в разделе "Мой аккаунт"
  2. Выйти
  3. Вход назад в
  4. Уйдите в течение 30 минут
  5. Есть еще var_dump()

сейчас , Я главный специалист по информационным технологиям, и до сих пор я никогда не видел компьютерную магию.

Но если серьезно, вероятно, было сохранить старые куки относительно моей информации пользователя, пока я не вышел из системы, а затем обратно.

+1

Слава богу за эту находку, иначе я бы с ума сходил навсегда, пытаясь понять это –

Смежные вопросы