Warning: This function has been deprecated. Use wp_get_current_user() instead.
get_currentuserinfo()
Populate global variables with information about the currently logged in user.
描述
返回值
(bool|WP_User) False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise.
源代码
File: wp-includes/pluggable-deprecated.php
function get_currentuserinfo() {
_deprecated_function( __FUNCTION__, '4.5.0', 'wp_get_current_user()' );
return _wp_get_current_user();
}
更新日志
Version | 描述 |
---|---|
4.5.0 | Use wp_get_current_user() |
0.71 | Introduced. |
相关函数
Uses
-
wp-includes/user.php:
_wp_get_current_user() -
wp-includes/functions.php:
_deprecated_function()
-
Skip to note content
You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
Contributed by
Codex
Default Usage
The call to get_currentuserinfo() places the current user’s info into$userdata
, where it can be retrieved using member variables.<?php global $current_user; get_currentuserinfo(); printf( __( 'Username: %s', 'textdomain' ), esc_html( $current_user->user_login ) ) . '<br />'; printf( __( 'User email: %s', 'textdomain' ), esc_html( $current_user->user_email ) ) . '<br />'; printf( __( 'User first name: %s', 'textdomain' ), esc_html( $current_user->user_firstname ) ) . '<br />'; printf( __( 'User last name: %s', 'textdomain' ), esc_html( $current_user->user_lastname ) ) . '<br />'; printf( __( 'User display name: %s', 'textdomain' ), esc_html( $current_user->display_name ) ) . '<br />'; printf( __( 'User ID: %s', 'textdomain' ), esc_html( $current_user->ID ) );
Result:
Username: Zedd
User email: my@email.com
User level: 10
User first name: John
User last name: Doe
User display name: John Doe
User ID: 1
你可能对这些文章感兴趣:
- wordpress函数get_the_posts_navigation()用法示例
- wordpress函数get_the_title()用法示例
- wordpress函数get_the_terms()用法示例
- wordpress函数get_the_tags()用法示例
- wordpress函数get_the_taxonomies()用法示例
- wordpress函数get_the_permalink()用法示例
- wordpress函数get_the_password_form()用法示例
- wordpress函数get_the_posts_pagination()用法示例
- wordpress函数get_the_modified_date()用法示例
- wordpress函数get_the_modified_time()用法示例
- wordpress函数get_the_modified_author()用法示例
- wordpress函数get_the_guid()用法示例
- wordpress函数get_the_ID()用法示例
- wordpress函数get_the_generator()用法示例
如有疑问,请前往问答中心反馈!
反馈