Php Wordpress获取名字和姓氏
我试图使用以下代码在Wordpress中获取用户的名字:Php Wordpress获取名字和姓氏,php,wordpress,Php,Wordpress,我试图使用以下代码在Wordpress中获取用户的名字: global $current_user; get_currentuserinfo(); var_dump($current_user); 。。。我的输出在文章的末尾 根据,我应该能够获取用户的名字和姓氏。然而,模仿他们的例子将是徒劳的,因为user\u firstname和user\u lastname都不会显示在这个变量转储中 为什么不呢?我使用的是Wordpress 3.5.1,我的WP帐户设置了名字和姓氏 谢谢你抽出时间 输出:
global $current_user;
get_currentuserinfo();
var_dump($current_user);
。。。我的输出在文章的末尾
根据,我应该能够获取用户的名字和姓氏。然而,模仿他们的例子将是徒劳的,因为user\u firstname
和user\u 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
哇!它现在正在工作
但说真的,我可能会保留关于我用户信息的旧cookie,直到我注销后再重新登录。你登录了吗?我想你知道这一点,但你需要登录才能让它工作。@AndyWarren是的。除了名字和姓氏之外,它能得到我所有的信息。感谢上帝让我找到了这个发现,否则我会因为试图弄明白它而发疯