• Resolved heywatchoutdude

    (@heywatchoutdude)


    Hi,

    is it possible to reverse the “Force Login” Plugin, which means I only want to enforce a login for pages/sites I have specified in the functions.php file. (not for all)

    Thanks!

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

    (@kevinvess)

    Hi–

    You may activate the plugin per site if you’re using a multisite install. It does not need to be “network enabled” for all sites in WordPress multisite.

    Otherwise, you could use the v_forcelogin_bypass filter to always be true then set a conditional statement to be false for specific pages that you want to enforce the login. For example:

    /**
     * Bypass Force Login.
     *
     * @param bool $bypass Whether to disable Force Login. Default false.
     * @return bool
     */
    function my_forcelogin_bypass( $bypass ) {
      // Allow all to be publicly accessible
      $bypass = true;
    
      // Force login for specific pages
      if ( is_page( 7 ) ) {
        $bypass = false;
      }
    
      return $bypass;
    }
    add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass' );

    However, if you only need to require login for a few specific pages, I recommend coding a custom redirect solution for only those pages. Force Login is primarily a full site solution.

    Good luck!

    Thread Starter heywatchoutdude

    (@heywatchoutdude)

    Hi Kevin,

    thanks that works like a charm ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Reverse “Force Login”’ is closed to new replies.