Is Proforms still using the wp error code handling the form login error?

I’ve tried

function my_custom_error_messages( $error ) {
global $errors;
$err_codes = $errors->get_error_codes();
// Invalid username.
// Default: '<strong>ERROR</strong>: Invalid username. <a href="%s">Lost your password</a>?'
if ( in_array( 'invalid_username', $err_codes ) ) {
$error = 'Oops, it looks like the username you is not valid. Please double-check and try again.';
}
// Incorrect password.
// Default: '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s">Lost your password</a>?'
if ( in_array( 'incorrect_password', $err_codes ) ) {
$error = 'Uh oh, the password seems not right. Please double-check your password and retry.';
}
return $error;
};
add_filter( 'login_errors', 'my_custom_error_messages' );

inside the function.php under the child theme, but that didn’t seem to take effect?

Try this:

function my_custom_error_messages( $error ) {
    // Getting error codes from the error message
    $err_codes = explode(',', strip_tags($error));

    // Invalid username.
    if ( in_array( 'invalid_username', $err_codes ) ) {
        $error = 'Oops, it looks like the username you entered is not valid. Please double-check and try again.';
    }

    // Incorrect password.
    if ( in_array( 'incorrect_password', $err_codes ) ) {
        $error = 'Uh oh, the password seems not right. Please double-check your password and retry.';
    }

    return $error;
}
add_filter( 'login_errors', 'my_custom_error_messages' );

If that does not work, try this:

function my_custom_error_messages( $error ) {
    global $errors;
    $err_codes = $errors->get_error_codes();

    // Invalid username.
    if ( in_array( 'invalid_username', $err_codes ) ) {
        $error = __( 'Oops, it looks like the username you entered is not valid. Please double-check and try again.', 'bricks' );
    }

    // Incorrect password.
    if ( in_array( 'incorrect_password', $err_codes ) ) {
        $error = __( 'Uh oh, the password seems not right. Please double-check your password and retry.', 'bricks' );
    }

    return $error;
}

add_filter( 'login_errors', 'my_custom_error_messages' );

@div You are awesome! :metal: :metal: the first code work for me! Thanks a lot.

2 Likes