Password recovery function is no longer working

I created a custom registration/login page in order to have a ccap that could then be carried to ActiveCampaign and trigger a particular welcome automation.

On this page: http://scrapbookcampus.com/login/
you can sign up or login. That is working perfectly however, i noticed (from emails i received) that this seems to have disabled the Password recovery function too as it just comes back to the same page.

In order to “force” the use of that particular page (so the ccap be added), i had to use a redirect in the ,htaccess file so that nobody would be able to use the default login.php page from WP, but is that now, causing the password recovery function to NOT WORK anymore?

Am i missing something? Did i forget something? Do i need to add something to the code?

Thanks.

If you have added code in your .htaccess file to redirect away from wp-login.php, then that will indeed prevent password recovery from working, because that also uses the wp-login.php page (although I agree that WP makes this less than clear).

My advice is, where possible, ALWAYS do redirections using a PHP function in your (child) theme’s functions.php file. The .htaccess file is probably the most temperamental part of WordPress, and I like to give it as little reason to play up as possible.

Since i am not a coder, how should i do that?

Carole,

There are several alternatives, because it depends on how exactly you have things set up. Do you want to have just one login page, for example, and just one registration page? Or do you want to have more than one of each?

I just want to have that one i linked above, so i can “control” the application of a ccap for any free registration.

OK, in that case I suggest you try adding this to your functions.php file:

// Redirects to new login page
function redirect_to_new_login_page( $login_url, $redirect ) {
return esc_url( home_url( '/login/?redirect_to=' . $redirect ) );
}
add_filter( 'login_url', 'redirect_to_new_login_page', 10, 2 );

I tried adding the code as you wrote it and it is not working. The Forget Password still keeps me on the same page. I get the correct redirect to the specific page, the Signup link works but the Forgot Password link does nothing.

OK, time for the big guns then! Try this instead:

function possibly_redirect(){
global $pagenow;
if( 'wp-login.php' == $pagenow ) {
if ( isset( $_POST['wp-submit'] ) ||   // in case of LOGIN
( isset($_GET['action']) && $_GET['action']=='logout') ||   // in case of LOGOUT
( isset($_GET['checkemail']) && $_GET['checkemail']=='confirm') ||   // in case of LOST PASSWORD
( isset($_GET['checkemail']) && $_GET['checkemail']=='registered') ) return;    // in case of REGISTER
else wp_redirect( home_url('/login/') );
exit();
}
}
add_action('init','possibly_redirect');

function s2_redirect($redirect, $vars = array()) {
if ( (isset($_GET['action']) && $_GET['action'] != 'logout') || (isset($_POST['login_location']) && !empty($_POST['login_location'])) ) {
$redirect = $_SERVER['HTTP_REFERER'];
return $redirect;
}
}
add_filter("ws_plugin__s2member_login_redirect", "s2_redirect", 10, 2);`

No luck. Same result.

Then you have some sort of conflict. Luckily, another user has posted a solution today for just such a situation. Try using the code here instead: Page to recovery password not found

That thread refers to Woocommerce and i have nothing of the sort. I’ll have to dig further.
Since i don`t understand the code itself, i wonder if it should replace what i have or add to it?

I’d start by using this code instead of all the code I suggested before.

Although the thread to which I referred talks about WooCommerce, the code isn’t about WooCoomerce at all. All that it’s doing is forcing your lost password page to be the default WP lost password page (because evidently you have something that is currently preventing that).

So, after adding just this code, see (a) whether the login page and (b) the lost password page work as you want. If both work, that’s all you need.

If (b) doesn’t work, you are going to have to work out what’s causing the conflict.

If (b) works but (a) doesn’t, then just add the very first piece of code I suggested, and try it again.

OK adding that other code remove my expected redirect to the specific “login” page i had set up, and it goes to the regular wp login page (which i dont want because i cant add a ccap from that page). In addition, on that regular WP login page, the Forgot Password still doesn`t work.

So i had to revert to the previous code so at least i get redirected to the correct login.

The significant thing here (because we know we can always get the login page right) is that it still doesn’t allow the lost password page to function.

So you really need to identify what is causing that problem before you can go any further. I suspect it’s a plugin conflict.

I`ll to dig further then. I checked all the plugins against my test site, and everything is the same yet on the test site, the password recovery works. I also deactivated all the plugins (except s2M and ezphp) and even then the password recovery still does not work.

In that case, have you got anything else in your .htaccess file that might be blocking the password recovery function?

Hey Tim, after more testing, i found the culprit: the Maintenance plugin. Since i was putting the site on maintenance mode to deactivate everything, i was keeping that plugin active, meaning, i kept the culprit in the house.

Now that i know, it will be easy to manage: if i need to put the site on Maintenance mode, it means that nobody should log in anyways, so i’ll just reactivate it when i need it, so it won’t affect the login, or the password reset.

Yay!

Great! Thanks for letting me know!