• Resolved dougcoxnc

    (@dougcoxnc)


    Hello,

    I am using this plugin to require login for my site. But I need the password reset link to work, and it currently does not.

    I am trying to use this code

    `//**
    * Bypass Force Login to allow for exceptions.
    *
    * @return bool Whether to disable Force Login. Default false.
    */
    function my_forcelogin_bypass( $bypass ) {
    if ( class_exists( ‘WooCommerce’ ) ) {
    if ( is_wc_endpoint_url( ‘my-account/lost-password’ ) ) {
    $bypass = true;
    }
    }
    return $bypass;
    }
    add_filter( ‘v_forcelogin_bypass’, ‘my_forcelogin_bypass’ );

    But I get this error. I am using the Snippets plugin to insert it, but I also tried directly into the Functions.php

    The snippet has been deactivated due to an error on line 7:
    Cannot redeclare function my_forcelogin_bypass.

    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!

    You can’t use the same function name twice: my_forcelogin_bypass. You need to either rename one of them–?or make sure you only use that code in one place.

    Thread Starter dougcoxnc

    (@dougcoxnc)

    Kevin,

    Thank you for the quick response! So I made you suggestions, and it fixed the error. But then the code did let me get to that page I needed.

    So I switched to the your other code – Method 1

    SUCCESS!! Thanks again!!

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

    // Allow URL
    if ( ‘/my-account/lost-password/’ === $url_path ) {
    $bypass = true;
    }

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WooCommerce – Whitelist Password Reset link’ is closed to new replies.