On this page
wp_login( string $username, string $password, string $deprecated = '' ): bool
This function has been deprecated. Use wp_signon() instead.
Checks a users login information and logs them in if it checks out. This function is deprecated.
Description
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.
See also
Parameters
$usernamestring Required-
User's username
$passwordstring Required-
User's password
$deprecatedstring Optional-
Not used
Default:
''
Return
bool True on successful check, false on login failure.
Source
File: wp-includes/pluggable-deprecated.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| wp_authenticate() wp-includes/pluggable.php | Authenticates a user, confirming the login credentials are valid. |
| _deprecated_function() wp-includes/functions.php | Marks a function as deprecated and inform when it has been used. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Use wp_signon() |
| 1.2.2 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_login