can you help me, how can I change the lost password link to an email action with specified subject? I found that in the functions.php I can add a new filter like this:

add_filter( 'lostpassword_url',  'my_lostpassword_url', 10, 0 );
function my_lostpassword_url() {
    return site_url('/password-reset/');

But I dont know how can I implement the mailto action instead of the new url. Can you help me?

  • A mailto action is just a URL that starts with mailto: instead of http: or https:, the specifics of how a mailto URL is formatted or built though isn't a WordPress problem but a general HTML question
    – Tom J Nowell
    Sep 22, 2020 at 11:50
  • a quick google of "mailto url" gives this and a tonne of others lifewire.com/how-to-create-a-mailto-link-3466469, <a href="mailto:[email protected]">Send me an email</a>
    – Tom J Nowell
    Sep 22, 2020 at 11:51
  • :-) I know what is a mailto action, but my question was how can I implement into the code, what I wrote above. Please listen to my question before giving an unnecessarily wrong answer. Thank you!
    – Blackdog
    Sep 22, 2020 at 13:37
  • These aren't answers, they're comments, answers will appear underneath with voting controls and their own comments. Note that any answer you get will require basic programming knowledge, it won't be a copy paste solution. Can you expand on what's missing that you don't understand or have? Is the code above code that you wrote? How familiar are you with filters
    – Tom J Nowell
    Sep 22, 2020 at 14:08
  • So, I have a webpage, where I'd like to control the lost passwords. I disabled earlier the reset password option under WP. I searched and found an answer in this forum, where somebody want the change the default lost password page url. This is the code about I wrote. I don't want another page with another url for lost password, but if somebody lost his password then write me an e-mail with subject lost password. If I write it in a html page then it is a simple <a href="mailto:[email protected]?subject=Mail from Our Site">Email Us</a>
    – Blackdog
    Sep 22, 2020 at 17:37

1 Answer 1


This answer assumes you're running PHP 5.3 or above.

Use the filter code below in-place of your code that you quoted above. Then simply update the variables provided so that it's sending to the correct email address and with the particular subject you'd like.

add_filter( 'lostpassword_url', function () {
    $email_to = '[email protected]';
    $email_subject =  'Help I lost my password';
    return sprintf( 'mailto:%s?subject=%s', $email_to, $email_subject );
}, 100, 0 );

Note: You cannot change the anchor text "Lost Password" that is used in the link.

  • Thank you very much!
    – Blackdog
    Sep 24, 2020 at 15:51

Your Answer

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

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