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?
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?
Share Improve this question edited Sep 22, 2020 at 11:51 Tom J Nowell♦ 61k7 gold badges79 silver badges148 bronze badges asked Sep 22, 2020 at 11:38 BlackdogBlackdog 31 bronze badge 6 | Show 1 more comment1 Answer
Reset to default 0This 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.
mailto:
instead ofhttp:
orhttps:
, the specifics of how amailto
URL is formatted or built though isn't a WordPress problem but a general HTML question – Tom J Nowell ♦ Commented Sep 22, 2020 at 11:50<a href="mailto:[email protected]">Send me an email</a>
– Tom J Nowell ♦ Commented Sep 22, 2020 at 11:51<a href="mailto:[email protected]?subject=Mail from Our Site">Email Us</a>
– Blackdog Commented Sep 22, 2020 at 17:37