• Resolved meadows19

    (@meadows19)


    Hello

    Firstly, I want to thank the author for making this plugin! I can see he’s spent a lot of time and effort behind it.

    I have the front page of my website locked down to non logged-in users. But I need to whitelist some dynamic URLs that build off the font page.

    They are:
    https://www.example.com/?crfw_cart_hash=op&[email protected]&crfw_action=checkout

    and

    https://www.example.com/?rcpga-invite-key=%24P%24BYO7dSbb544rPI%2FgNKxWseQZLRr8Lz%2F&rcpga-user=jimbob%2B1234%40gmail.com

    So basically any URL starting with
    https://www.example.com/?crfw_cart_hash

    or

    https://www.example.com/?rcpga-invite-key
    needs to go through.

    I’ve looked at the Github page here: Whitelist Dynamic URLs but I’m finding it quite difficult to understand because there are no worked-through examples.

    Can anyone please help? Thank you kindly.

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

    (@kevinvess)

    Hi, thanks for using Force Login!

    I believe the example you’re looking for is Method 3 – Page URL based on Query String Parameter(s) and/or Value(s).

    Just replace the parameter and/or value in the example with yours. Also, you probably only want the first if conditional statement for whitelist URL if query string contains ‘parameter’.

    Keep in mind though, if anyone adds those query strings to any page URL, it won’t require the visitor to login – unless you add another condition to the if statement to check if it’s the home page too.

    Good luck!

    Thread Starter meadows19

    (@meadows19)

    Hello
    Thank you for your reply and suggestions. I had a go at figuring it out. Does this seem like it would work?

    /**
     * Filter Force Login to allow exceptions for specific URLs.
     *
     * @return array An array of URLs. Must be absolute.
     **/
     
    function my_forcelogin_whitelist( $whitelist ) {
    
      // whitelist URL if query string contains 'parameter'
    
      if( is_home() && (isset($_GET['rcpga-invite-key']) || isset($_GET['crfw_cart_hash'])) ) 
      {
        $whitelist[] = site_url($_SERVER['REQUEST_URI']);
      }
    
      return $whitelist;
    }
    
    add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);

    My other question is: what’s the difference between the Bypass Force Login function and the Whitelist URLs function? And when would I use one or the other?

    Thank you once again for this plugin and for your help.

    Plugin Author Kevin Vess

    (@kevinvess)

    I had a go at figuring it out. Does this seem like it would work?

    That looks correct to me – try it and see if it works. If it doesn’t, turn on WP_DEBUG mode and troubleshoot.

    […] what’s the difference between the Bypass Force Login function and the Whitelist URLs function?

    They’re fairly similar and often used for the same goal of allowing visitors to view certain pages or posts based on certain conditions. However, one achieves the goal based on the exact URL and the other is based on a boolean (true|false) condition.

    The whitelist filter is for specifying an array of exact URLs to allow visitors to view those pages without being forced to login. For example, if you only wanted to allow visitors to view the page with the exact URL: “http://www.domain.com/my-page/”

    The bypass filter is for specifying a boolean (true|false) value based on any condition. For example, instead of whitelisting every individual blog post URL, you could just bypass the login if the condition of is_single() returns true.

    You can read more about the bypass filter on my LinkedIn post here:
    https://www.linkedin.com/pulse/new-features-force-login-50-kevin-vess

    Thanks!

    • This reply was modified 9 years, 4 months ago by Kevin Vess. Reason: added links for reference
    Thread Starter meadows19

    (@meadows19)

    Thank you. I’ll give it a try.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Whitelist examples’ is closed to new replies.