drap5081683 2017-10-16 16:25
浏览 114
已采纳

Wordpress - get_user_by()返回false

I must be doing something wrong, but the following commented code returns false. Note that WP is returning 'admin' as the 'user_login', but when that user_login is used for the get_user_by() function it simply returns false. Am I missing something?

$user = get_userdata(1); // (admin ID is 1)

var_dump($user->user_login); // string(5) 'admin'
var_dump(get_user_by('user_login', $user->user_login)); // bool(false)

I am running WordPress 4.8.2

  • 写回答

2条回答 默认 最新

  • dongma7725 2017-10-16 16:27
    关注

    I believe you'll need to use "login" rather by "user_login" in the get_user_by call.

    See the posssible accepted values of the function here: https://developer.wordpress.org/reference/functions/get_user_by/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan