• Resolved bilievesser

    (@bilievesser)


    So I have previousy used all this code to help bypass necessary functions for a members only WooCommerce shop. Now I get php noticed to change v_forcelogin_whitelist to v_forcelogin_bypass – but I’m already using that name. How can I merge the two functions below into one, or minimize everything? The resetpass bypass needs to take into account dynamic URLs…

    Thanks ??

    /**
     * Filter Force Login to allow exceptions for specific URLs.
     *
     * @param array $whitelist An array of URLs. Must be absolute.
     * @return array
     */
    function my_forcelogin_whitelist( $whitelist ) {
      $whitelist[] = home_url( '/login/' );
      $whitelist[] = home_url( '/logout/' );
      $whitelist[] = home_url( '/register/' );
      $whitelist[] = home_url( '/lostpassword/' );
    
      return $whitelist;
    }
    add_filter( 'v_forcelogin_whitelist', 'my_forcelogin_whitelist' );
    
    /**
     * Bypass Force Login to allow for exceptions.
     *
     * @param bool $bypass Whether to disable Force Login. Default false.
     * @return bool
     */
    function my_forcelogin_bypass( $bypass ) {
      if ( is_page('resetpass') ) {
        $bypass = true;
      }
      return $bypass;
    }
    add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass' );
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Kevin Vess

    (@kevinvess)

    Hi, thanks for using Force Login!

    You can find examples of how to add exceptions for absolute URLs (similar to the old whitelist filter) or dynamic URLs in the Frequently Asked Questions section.

    Thanks!

    Thread Starter bilievesser

    (@bilievesser)

    Thanks for your response, however I just can’t get this working. I’ve tried every possible combination, but dynamic URLs is not working.

    I need to bypass the following:
    /login
    /logout
    /register
    /lostpassword

    And, when a user is resetting the password, I need the URL they get back on email to be bypassed, which looks like this:/resetpass/?key=XXX&login=XXX

    Any ideas?

    I would be super happy for a complete code that would include all these bypasses ??

    Plugin Author Kevin Vess

    (@kevinvess)

    The example in the FAQs shows how to add exceptions to pages like yours.

    Unfortunately, I won’t be able to troubleshoot this issue without access to your website. I recommend hiring a developer to help you customize the plugin to work for your needs.

    Thanks and good luck!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help with merging filters’ is closed to new replies.