0

I tried login_message filter with $_GET['action'] && resetpass but I want it on success password message page.

1
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Feb 14 at 16:03

1 Answer 1

0

You want to change the "Your password has been reset." message.

You say you've tried the login_message filter and that should work, so your problem is likely that your code isn't getting loaded. Put your filter code in a mu-plugin not a regular plugin to ensure it gets loaded for the login page. Rather than testing for the action I'd test if the message contains __( 'Your password has been reset.' ) instead.

Here's the code from wp-login.php:

login_header(
    __( 'Password Reset' ),
    wp_get_admin_notice(
        __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a>',
        array(
            'type'               => 'info',
            'additional_classes' => array( 'message', 'reset-pass' ),
        )
    )
);

As you can see there's nothing obvious to filter there. You could also

  1. Use a gettext filter to catch exact matches for "Your password has been reset." and replace it with your own string, e.g. see this answer. I don't particularly like this, but you're already having to check for a text match 🤷‍♀️ so maybe it's not too bad.
  2. Filter wp_admin_notice_markup instead. Here you could check for the reset case using the additional_classes argument containing reset-pass, but you're going to have to make a string substitution into the message mark-up too, so this isn't very nice either.

So there aren't any particularly good options here, sorry.

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.