get_user_id_from_string() - WordPress 函数参考中文文档

返回介绍

get_user_id_from_string()

发布于 2017-09-11 字数1598 浏览 1007 评论 0

Warning: This function has been deprecated. Use get_user_by() instead.

get_user_id_from_string( string $string )

Get a numeric user ID from either an email address or a login.


描述

A numeric string is considered to be an existing user ID and is simply returned as such.


参数

$string

(string)
(Required)
Either an email address or a login.


返回值

(int)


源代码

File: wp-includes/ms-deprecated.php

function get_user_id_from_string( $string ) {
	_deprecated_function( __FUNCTION__, '3.6.0', 'get_user_by()' );

	if ( is_email( $string ) )
		$user = get_user_by( 'email', $string );
	elseif ( is_numeric( $string ) )
		return $string;
	else
		$user = get_user_by( 'login', $string );

	if ( $user )
		return $user->ID;
	return 0;
}

更新日志

Version 描述
3.6.0 Use get_user_by()
MU Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    is_email()
  • wp-includes/pluggable.php:
    get_user_by()
  • wp-includes/functions.php:
    _deprecated_function()

User Contributed Notes

上一篇:get_user_details()

下一篇:get_user_locale()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!