我需要为每个新成员生成一个唯一的ID号。我本来打算使用WP\\u查询,但只得到一个数组。
如何在用户元中回显用户ID?
1 个回复
SO网友:Evan Yeung
如果要显示当前登录用户的信息,可以使用get_currentuserinfo
. [Codex]
Codex中的示例
<?php global $current_user;
get_currentuserinfo();
echo \'Username: \' . $current_user->user_login . "\\n";
echo \'User email: \' . $current_user->user_email . "\\n";
echo \'User first name: \' . $current_user->user_firstname . "\\n";
echo \'User last name: \' . $current_user->user_lastname . "\\n";
echo \'User display name: \' . $current_user->display_name . "\\n";
echo \'User ID: \' . $current_user->ID . "\\n";
?>
或者,如果要显示非当前登录用户的信息,可以使用get_userdata
. [Codex]WP Codex的两个链接应为您提供这两个函数的语法。如果您有任何进一步的问题或他们没有工作,请询问。
结束