Support » Plugin: Force Login » How can I add exceptions for certain pages or posts?

  • Resolved Omar

    (@onabhani)


    Hello,
    Thank you for your great plugin.

    Actually, I follow your instructions to bypass one URL in my system but it didn’t work at all. Please take note that my site is Multisite and I am using the plugin only on a subsite.

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

    (@kevinvess)

    Hi, thanks for using Force Login!

    If you share your custom code you tried, I could see if that is structured properly. Also, run some tests to ensure where you placed your code is working on the desired subsite.

    Unfortunately, I’m unable to help troubleshoot with such limited information and without access to your site and the hosting environment.

    I recommend you hire a web developer to help you customize this for your site.

    Good luck!

    Thread Starter Omar

    (@onabhani)

    Hello Kevin,

    I am sorry for not providing enough information.

    Actually, I used a code that you already shared on the plugin page:
    /**
    * Bypass Force Login to allow for exceptions.
    *
    * @param bool $bypass Whether to disable Force Login. Default false.
    * @param string $visited_url The visited URL.
    * @return bool
    */
    function my_forcelogin_bypass( $bypass, $visited_url ) {

    // Allow these absolute URLs
    $allowed = array(
    home_url( ‘Page URL HERE’ ),
    );
    if ( ! $bypass ) {
    $bypass = in_array( $visited_url, $allowed );
    }

    return $bypass;
    }
    add_filter( ‘v_forcelogin_bypass’, ‘my_forcelogin_bypass’, 10, 2 );

    I am adding the code at function.php of the theme which I am using for my Site and subsite. I will see how to solve this, Thank you for your time.

    Plugin Author Kevin Vess

    (@kevinvess)

    Looking at the code you shared, make sure you’re using a relative path with the home_url() function, or don’t use that function at all and just list an absolute URL.

    For example:

    home_url( '/path/page/' ),

    OR

    'https://domain.com/path/page/',

    Good luck!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.