get_user_by
函数
get_user_by ( $field, $value )
- 参数
-
-
(string)
$field
The field to retrieve the user with. id | ID | slug | email | login.- Required: 是
-
(int|string)
$value
A value for $field. A user ID, slug, email address, or login name.- Required: 是
-
(string)
- 返回值
-
- (WP_User|false) WP_User object on success, false on failure.
- 定义位置
-
-
wp-includes/pluggable.php
, line 101
-
wp-includes/pluggable.php
- 引入
- 2.8.0
- 弃用
- –
Retrieves user info by a given field.
function get_user_by( $field, $value ) { $userdata = WP_User::get_data_by( $field, $value ); if ( ! $userdata ) { return false; } $user = new WP_User; $user->init( $userdata ); return $user; } endif; if ( ! function_exists( 'cache_users' ) ) : /** * Retrieves info for user lists to prevent multiple queries by get_userdata(). * * @since 3.0.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @param int[] $user_ids User ID numbers list */
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。