Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress获取名字和姓氏_Php_Wordpress - Fatal编程技术网

Php 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帐户设置了名字和姓氏 谢谢你抽出时间 输出:

我试图使用以下代码在Wordpress中获取用户的名字:

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

哇!它现在正在工作

  • 在“我的帐户”下设置名字和姓氏
  • 注销
  • 重新登录
  • 离开30分钟
  • 执行另一个var_dump()
  • 现在,我是计算机科学专业的学生,到现在为止我还从未见过计算机魔术


    但说真的,我可能会保留关于我用户信息的旧cookie,直到我注销后再重新登录。

    你登录了吗?我想你知道这一点,但你需要登录才能让它工作。@AndyWarren是的。除了名字和姓氏之外,它能得到我所有的信息。感谢上帝让我找到了这个发现,否则我会因为试图弄明白它而发疯