Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter airadev1129

    (@airadev1129)

    I suspect your issue is related to the bypass code allowing access to any WooCommerce page or endpoint

    Thank you for your response.
    Even I remove the Woocommerce bypass, it is still not being blocked and according to the Force Login description, it is supposed to block all by default.

    Could this be a bug?

    Thread Starter airadev1129

    (@airadev1129)

    I need to require login to /design-editor/

    Here is my code:

    /**
     * fix custom login, remove redirects
     */
    function my_login_page( $login_url) {
        return site_url( '/my-account/');
    }
    add_filter( 'login_url', 'my_login_page', 10, 2 );
    
    /**
     * Bypass Force Login to allow for exceptions.
     *
     * @param bool $bypass Whether to disable Force Login. Default false.
     * @return bool
     */
    function my_forcelogin_bypass( $bypass ) {
      // Allow all WooCommerce pages and endpoints
      if ( class_exists( 'WooCommerce' ) ) {
        if ( is_woocommerce() || is_wc_endpoint_url() ) {
          $bypass = true;
        }
      }
      
    // page
        if ( is_page( array( 'home', 'terms-privacy', 'affiliate-disclosure', 'blog' ) ) ) {
        $bypass = true;
      }
      
    
    // blogpost
        if ( is_single() ) {
        $bypass = true;
      }
    
      return $bypass;
    }
    add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass' );
    • This reply was modified 3 years, 4 months ago by airadev1129.
Viewing 2 replies - 1 through 2 (of 2 total)