• Resolved eswar123

    (@eswar123)


    Hi,
    the plugin is awesome and it works well, but I have a question.
    I want to restrict to only single posts. Is there any way to allow (exception) to home page, pages, etc…
    please can you suggest me the code to restrict only single posts? thank you

    The page I need help with: [log in to see the link]

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

    (@kevinvess)

    Hi, thanks for using Force Login!

    Force Login is built to make all pages private with the option to allow only a few pages or content types to be publicly accessible.

    With that said, you could add an exception for all content types except posts by adding the following code snippet to your functions.php file:

    /**
     * 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_single() ) {
        $bypass = true;
      }
      return $bypass;
    }
    add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass' );
    Thread Starter eswar123

    (@eswar123)

    Thank you so much

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘restrict only single post’ is closed to new replies.