Title: Whitelist examples
Last modified: January 21, 2017

---

# Whitelist examples

 *  Resolved [meadows19](https://wordpress.org/support/users/meadows19/)
 * (@meadows19)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/whitelist-examples/)
 * 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&crfw_email=jimbob@gmail.
   com&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](https://github.com/kevinvess/wp-force-login/wiki/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](https://wordpress.org/support/users/kevinvess/)
 * (@kevinvess)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/whitelist-examples/#post-8687823)
 * 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)](https://github.com/kevinvess/wp-force-login/wiki/Whitelist-Dynamic-URLs#method-3---page-url-based-on-query-string-parameters-andor-values).
 * 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](https://wordpress.org/support/users/meadows19/)
 * (@meadows19)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/whitelist-examples/#post-8688337)
 * 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](https://wordpress.org/support/users/kevinvess/)
 * (@kevinvess)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/whitelist-examples/#post-8688498)
 * > 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](https://codex.wordpress.org/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/&#8221](http://www.domain.com/my-page/&#8221);
 * 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()](https://developer.wordpress.org/reference/functions/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](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](https://wordpress.org/support/users/kevinvess/).
      Reason: added links for reference
 *  Thread Starter [meadows19](https://wordpress.org/support/users/meadows19/)
 * (@meadows19)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/whitelist-examples/#post-8688648)
 * 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.

 * ![](https://ps.w.org/wp-force-login/assets/icon.svg?rev=1904031)
 * [Force Login](https://wordpress.org/plugins/wp-force-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-force-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-force-login/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-force-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-force-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-force-login/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [meadows19](https://wordpress.org/support/users/meadows19/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/whitelist-examples/#post-8688648)
 * Status: resolved