• Resolved mehdiag2r

    (@mehdiag2r)


    Hi

    I’am using force login for my wordpress and i need to add a exception for a special path in the wordpress api.

    I have try with the filter v_forcelogin_bypass but that dont work with my api path.

    I use register_rest_route function for register my route.

    The reponse is:

    {
        "code": "rest_unauthorized",
        "message": "Seuls les utilisateurs authentifiés peuvent accéder à l’API REST.",
        "data": {
            "status": 401
        }
    }

    Thanks for the help

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

    (@kevinvess)

    Hi– thanks for using Force Login!

    The bypass filter allows you to add an exception for the login redirect.

    Your issue is with the restriction to the REST API for authorized users, you may allow the REST API to be publicly accessible again by adding one of the following code snippets to your functions.php file:

    add_filter( 'rest_authentication_errors', '__return_true' );

    OR

    remove_filter( 'rest_authentication_errors', 'v_forcelogin_rest_access', 99 );

    Thread Starter mehdiag2r

    (@mehdiag2r)

    Hi Kevin,

    Thanks for help it is working.

    I do that:

    
    add_action('parse_request', 'my_custom_url_handler', 1, 1);
    
    function my_custom_url_handler() {
       if(stripos($_SERVER["REQUEST_URI"], 'my-url')) {
          add_filter( 'rest_authentication_errors', '__return_true' );
       }
    }
    

    That disabled only for my path and not the all api.

    Best regard

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exception for api’ is closed to new replies.