apply_filters( 'wp_authenticate_user', WP_User|WP_Error $user, string $password )

Filters whether the given user can be authenticated with the provided $password.


Parameters Parameters

$user

(WP_User|WP_Error) WP_User or WP_Error object if a previous callback failed authentication.

$password

(string) Password to check against the user.


Top ↑

Source Source

File: wp-includes/user.php

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Sanjeev Aryal

    Example Code:

    /**
     * Check User Status.
     *
     * @param $user WP_User Object
     */
    function check_status( WP_User $user ) {
    
    	$status = get_user_meta( $user->ID, 'user_status' );
    
    	if ( 1 !== (int) $status ) {
    		$message = esc_html__( 'User not verified.', 'text-domain');
    		return new WP_Error( 'user_not_verified', $message );
       }
    
        return $user;
    }
    
    add_filter( 'wp_authenticate_user', 'check_status' );

You must log in before being able to contribute a note or feedback.