Support » Plugin: Force Login » Bypass the Plugin with WooCommerce ?add-to-cart=xxxxxx

  • Resolved Miguel A. Mendes

    (@miguelamendes9)


    Hi Kevin,

    How i do create a bypass for the WooCommerce add to cart values, like this “?add-to-cart=xxxxxxx”.

    Thank you for your help!

    Best regards,
    Miguel

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

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

    (@kevinvess)

    Hi– thanks for using Force Login!

    I suggest you try the v_forcelogin_bypass filter with the WooCommerce Conditional Tags.

    Check out this support thread for an example:
    https://wordpress.org/support/topic/whitelist-woocommerce/

    Hi Kevin,

    I have found that support thread and put that code in my functions.php but gives me an error and my website went down.

    /**
    * 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 ( class_exists( ‘WooCommerce’ ) ) {
    if ( is_woocommerce() || is_wc_endpoint_url() ) {
    $bypass = true;
    }
    }
    return $bypass;
    }
    add_filter( ‘v_forcelogin_bypass’, ‘my_forcelogin_bypass’ );

    I’m not a code guy, what i have to change on that code to to get add add-to-cart=xxxxxxx bypass?

    Thank you!

    Plugin Author Kevin Vess

    (@kevinvess)

    What is the error you’re getting?

    Hi Kevin,

    I resolve this issue with this bypass.

    Thank you for your help.

    /**
    * Bypass Force Login to allow for exceptions.
    *
    * @param bool $bypass Whether to disable Force Login. Default false.
    * @return bool
    */
    function my_forcelogin_bypass( $bypass ) {
    // Get visited URL without query string
    $url_path = preg_replace(‘/\?.*/’, ”, $_SERVER[‘REQUEST_URI’]);

    // Allow URL
    if ( ‘/?add-to-cart=’ === $url_path ) {
    $bypass = true;
    }

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

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