检查用户登录信息并在签出时将其登录。不推荐使用此功能。
原型
wp_login( string $username, string $password, string $deprecated = '' )
描述
使用全局$ error来获取登录失败的原因。如果用户名为空,则不会设置错误,因此假设该用户名为空白用户名。
参考:
- wp_signon()
参数
$username
(string)
(Required)
用户的用户名
$password
(string)
(Required)
用户密码
$deprecated
(string)
(Optional)
不曾用过
返回值
(bool)
登录失败时为false,成功检查时为true
源文件
路径:wp-includes/pluggable-deprecated.php
<?php
...
function wp_login($username, $password, $deprecated = '') {
_deprecated_function( __FUNCTION__, '2.5.0', 'wp_signon()' );
global $error;
$user = wp_authenticate($username, $password);
if ( ! is_wp_error($user) )
return true;
$error = $user->get_error_message();
return false;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_login/