wp_login
Checks a users login information and logs them in if it checks out.
Description
This function is deprecated.
Use the global $
to get the reason why the login failed. If the username is blank, no error
error
will be set, so assume blank username on that case.
Plugins extending this function should also provide the global $
and set what the error
error
is, so that those checking the global for why there was a failure can utilize it later.
Parameters (3)
- 0. $username (string)
- User's username
- 1. $password (string)
- User's password
- 2. $deprecated — Optional. (string) =>
''
- The deprecated.
Usage
if ( !function_exists( 'wp_login' ) ) { require_once ABSPATH . WPINC . '/pluggable-deprecated.php'; } // User's username $username = ''; // User's password $password = ''; // The deprecated. $deprecated = ''; // NOTICE! Understand what this does before running. $result = wp_login($username, $password, $deprecated);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/pluggable-deprecated.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;
- }