admin管理员组

文章数量:1207726

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?

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?

Share Improve this question asked Sep 19, 2014 at 2:41 OudinOudin 4194 gold badges9 silver badges18 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

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');
}

本文标签: filtersHow to changerewrite the lost password url