0

I'm looking to alter the message "Please enter your username or email address. You will receive an email message with instructions on how to reset your password" in the wp-login file.

If I change this directly I assume it'll revert back after a WordPress update. Is there a way to make it permanent or a plugin I can install to edit it from there?

Thanks

1 Answer 1

2

The login_message filter will allow you to change the message persisting through WordPress updates. I usually use an mu-plugin, but the below can also be added to your theme's functions.php.

Untested:

add_filter( 'login_message', static function ( $message ) {
    $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login';

    if ( ! in_array( $action, array( 'lostpassword', 'retrievepassword' ) ) ) {
        return $message;
    }

    return __( 'Your preferred message.' );
} );

You could compare directly to the core message as well, but that seems less reliable (untested):

add_filter( 'login_message', static function ( $message ) {
    $default = __( 'Please enter your username or email address. You will receive an email message with instructions on how to reset your password.' );

    if ( $default !== $message ) {
        return $message;
    }

    return __( 'Your preferred message.' );
} );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.