wp_login()
Deprecated since 2.5.0. It is no longer supported and may be removed in future releases. Use wp_signon() instead.
Checks a users login information and logs them in if it checks out. This function is deprecated.
Use the global $error to get the reason why the login failed. If the username is blank, no error will be set, so assume blank username on that case.
Plugins extending this function should also provide the global $error and set what the error is, so that those checking the global for why there was a failure can utilize it later.
No Hooks.
Returns
true|false
. True on successful check, false on login failure.
Usage
wp_login( $username, $password, $deprecated );
- $username(string) (required)
- User's username.
- $password(string) (required)
User's password.
It has the attribute
#[\SensitiveParameter]
, which hides the value of the parameter from logs. It is used to protect sensitive data (for example, passwords). Documentation.- $deprecated(string)
- Not used.
Default: ''
Notes
- See: wp_signon()
- Global. String. $error Error when false is returned
Changelog
Since 1.2.2 | Introduced. |
Deprecated since 2.5.0 | Use wp_signon() |
wp_login() wp login code WP 6.8.1
function wp_login( $username, #[\SensitiveParameter] $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; }