How to change/rewrite the lost password url?

I used iThemes Security (formerly Better WP Security) hide back-end functionality to change the login url to /signin however clicking the lost password link /wp-login.php?action=lostpassword now generate a 404

Manually going to /signin?action=lostpassword works.

I came across the following code below which is suppose to make the change to however after some testing it doesn’t seem to work

//*******************************************************
//Function to change to lost password url
//********************************************************
add_filter('site_url',  'wplogin_filter', 10, 3);
function wplogin_filter( $url, $path, $orig_scheme ){
    $old  = array( "/(wp-login\.php)/");
    $new  = array( "signin/"); //this can be change to login or whatever or may remain there
    return preg_replace( $old, $new, $url, 1);
}

add to .htaccess

RewriteRule ^signin$ wp-login.php

How can i modify the above code in order to change the url for the lost password?

1 Answer
1

the solution is simple, there is a filter to change the lost password url.
Try this :

add_filter( 'lostpassword_url',  'wdm_lostpassword_url', 10, 0 );
function wdm_lostpassword_url() {
    return site_url('/signin?action=lostpassword');
}

Leave a Comment