apply_filters( ‘wp_login_errors’, WP_Error $errors, string $redirect_to )

Filters the login page errors.

Parameters

$errorsWP_Error
WP Error object.
$redirect_tostring
Redirect destination URL.

Source

$errors = apply_filters( 'wp_login_errors', $errors, $redirect_to );

Changelog

VersionDescription
3.6.0Introduced.

User Contributed Notes

  1. Skip to note 2 content
    /**
     * Change the Register Success message 
     * @param WP_Error	$wp_error The WP_Error object.
     * @param string		Redirect destination URL.
     * 
     * @return WP_Error	$wp_error The WP_Error object.
     */
    add_filter( 'wp_login_errors', 'wpdocs_filter_wp_login_errors', 10, 2 );
    
    function wpdocs_filter_wp_login_errors( $errors, $redirect_to ) {
    	// Run Only if user registration is a success
    	if ( strpos( $_SERVER['REQUEST_URI'], 'checkemail=registered' ) !== false ) {
    
    		// Remove the existing Register success message
    		$errors->remove( 'registered' );
    
    		// make the changes to register message
    		$errors->add( 'registered', sprintf( __( 'Please check your Spam box if email is not to be found in inbox.' ), wp_login_url() ), 'message' );
    
    		return $errors;
    	} else {
    		// Return the other message and errors
    		return $errors;
    	}
    }

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