Title: wp_login
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_login( string $username, string $password, string $deprecated ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#wp--skip-link--target)

This function has been deprecated since 2.5.0. Use [wp_signon()](https://developer.wordpress.org/reference/functions/wp_signon/)
instead.

Checks a users login information and logs them in if it checks out. This function
is deprecated.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#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](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#see-also)󠁿

 * [wp_signon()](https://developer.wordpress.org/reference/functions/wp_signon/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#parameters)󠁿

 `$username`stringrequired

User’s username

`$password`stringrequired

User’s password

`$deprecated`stringrequired

Not used

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#return)󠁿

 bool True on successful check, false on login failure.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#source)󠁿

    ```php
    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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/pluggable-deprecated.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/pluggable-deprecated.php#L179)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/pluggable-deprecated.php#L179-L195)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_authenticate()](https://developer.wordpress.org/reference/functions/wp_authenticate/)`wp-includes/pluggable.php` |

Authenticates a user, confirming the login credentials are valid.

  | 
| [_deprecated_function()](https://developer.wordpress.org/reference/functions/_deprecated_function/)`wp-includes/functions.php` |

Marks a function as deprecated and inform when it has been used.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_login/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Deprecated. Use [wp_signon()](https://developer.wordpress.org/reference/functions/wp_signon/)  | 
| [1.2.2](https://developer.wordpress.org/reference/since/1.2.2/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_login%2F)
before being able to contribute a note or feedback.