Support » Plugin: Force Login » Reset Password Not Working

  • Resolved tcumpston

    (@tcumpston)


    Hi Kevin

    I’m using the following code for my site.

    function my_forcelogin_bypass( $bypass, $visited_url ) {
      // Allow all single posts
      if ( is_single() ) {
        $bypass = true;
      }
    
      // Allow these absolute URLs
      $allowed = array(
        home_url( '/registration/' ),
    	home_url( '/lostpassword/' ),
    	home_url( '/resetpass/?' . $_SERVER['QUERY_STRING'] ),
        home_url( '/resetpass.php?' . $_SERVER['QUERY_STRING'] ),
      );
      if ( ! $bypass ) {
        $bypass = in_array( $visited_url, $allowed );
      }
    
      return $bypass;
    }
    add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass', 10, 2 );

    I can get to the registration page with no problems. But when I request a password reset, the link I get from WP (https://web-url-here.com/resetpass/?key=CbefWxxFNCMzJcupFxkA&login=user-name) takes me back to the login page and doesn’t allow for the reset. What am I doing wrong?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Kevin Vess

    (@kevinvess)

    Hi, thanks for using Force Login!

    First, I hope you realize you’re allowing all posts to be publicly accessible with the following lines of code:

    // Allow all single posts
    if ( is_single() ) {
      $bypass = true;
    }

    As for the registration page, this is difficult to troubleshoot since you’re using a custom registration URL and process. I recommend you find a better way to identify when the user is accessing a registration page to bypass it, instead of using the absolute URL method. For example:

    if ( is_page('registration') || is_page('resetpass') ) {
      $bypass = true;
    }

    Good luck!

    Thread Starter tcumpston

    (@tcumpston)

    Thanks Kevin. I removed the posts code (though we didn’t have any posts for people to access anyway). Thanks for the heads up. I switched over to the is_page and seems to be working better. Thank you for the quick reply.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Reset Password Not Working’ is closed to new replies.