先判断下是否登录,然后获取当前用户对象,然后获取当前用户对象的信息,需要哪些用哪些:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
if(is_user_logged_in()){
$current_user = wp_get_current_user();
echo 'Username: ' . $current_user->user_login . '
';
echo 'User email: ' . $current_user->user_email . '
';
echo 'User first name: ' . $current_user->user_firstname . '
';
echo 'User last name: ' . $current_user->user_lastname . '
';
echo 'User display name: ' . $current_user->display_name . '
';
echo 'User ID: ' . $current_user->ID . '
';
}