Switch language
wpseek on Twitter


A WordPress-centric search engine for devs and theme authors




wp_authenticate [ ]

wp_authenticate ( $username, $password )
Parameters:
  • (string) $username User's username
  • (string) $password User's password
Returns:
  • (WP_Error|WP_User) WP_User object if login successful, otherwise WP_Error object.
Defined at:
Codex



Checks a user's login information and logs them in if it checks out.

Source

function wp_authenticate($username, $password) {
	$username = sanitize_user($username);
	$password = trim($password);

	$user = apply_filters('authenticate', null, $username, $password);

	if ( $user == null ) {
		// TODO what should the error message be? (Or would these even happen?)
		// Only needed if all authentication handlers fail to return anything.
		$user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Invalid username or incorrect password.'));
	}

	$ignore_codes = array('empty_username', 'empty_password');

	if (is_wp_error($user) && !in_array($user->get_error_code(), $ignore_codes) ) {
		do_action('wp_login_failed', $username);
	}

	return $user;
}

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

0 User Note(s)

None yet. Be the first!

Add New ...