I'm new to WordPress. My question is,
Now default user forgot password redirecting to website/wp-login.php?action=lostpassword&redirect_to=http%3A%2F%2website%2Fuser-profile
But I have a custom page /password-reset/
. So I refer some post and added below code in my theme function.php
add_filter( 'lostpassword_url', 'my_lostpassword_url', 10, 0 );
function my_lostpassword_url() {
return site_url('/password-reset/');
}
But it's not working. So I added rewrite rule in .htaccess file - as first line
RewriteRule ^wp-login.php?action=lostpassword$ website/password-reset/ [R=301,L]
Both are not working. Any solution for this?
I'm new to WordPress. My question is,
Now default user forgot password redirecting to website/wp-login.php?action=lostpassword&redirect_to=http%3A%2F%2website%2Fuser-profile
But I have a custom page /password-reset/
. So I refer some post and added below code in my theme function.php
add_filter( 'lostpassword_url', 'my_lostpassword_url', 10, 0 );
function my_lostpassword_url() {
return site_url('/password-reset/');
}
But it's not working. So I added rewrite rule in .htaccess file - as first line
RewriteRule ^wp-login.php?action=lostpassword$ website/password-reset/ [R=301,L]
Both are not working. Any solution for this?
Share Improve this question edited Aug 26, 2019 at 7:45 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Aug 26, 2019 at 6:12 Neethu VargheseNeethu Varghese 136 bronze badges1 Answer
Reset to default 0I see what you're trying to do, but it appears you only "ALMOST" followed the code example provided by the codex.
Below is an annotated version of their sample code, substituting your desired URL:
// You need the "10,2" in for WP to pass their parameters .. you can ignore them from that point forward.
// 10 = Priority. Ensures it takes precedence, replacing the default.
// 2 = Allows WP to pass two parameters.
add_filter( 'lostpassword_url', 'my_lostpassword_url', 10, 2 );
function my_lostpassword_url( $lostpassword_url, $redirect ) {
// I recommend using the WP method, although you could use your return value
$redirect = '/password-reset/';
// Your url would also work. I just like the redirector...
return site_url( '/lostpassword/?redirect_to=' . $redirect );
}
Hope this helps!
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745211466a4616864.html
评论列表(0条)