Title: Exception for api
Last modified: November 5, 2021

---

# Exception for api

 *  Resolved [mehdiag2r](https://wordpress.org/support/users/mehdiag2r/)
 * (@mehdiag2r)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/exception-for-api/)
 * 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](https://wordpress.org/support/users/kevinvess/)
 * (@kevinvess)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/exception-for-api/#post-15048283)
 * 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](https://wordpress.org/support/users/mehdiag2r/)
 * (@mehdiag2r)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/exception-for-api/#post-15053672)
 * 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.

 * ![](https://ps.w.org/wp-force-login/assets/icon.svg?rev=1904031)
 * [Force Login](https://wordpress.org/plugins/wp-force-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-force-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-force-login/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-force-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-force-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-force-login/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [exception](https://wordpress.org/support/topic-tag/exception/)

 * 2 replies
 * 2 participants
 * Last reply from: [mehdiag2r](https://wordpress.org/support/users/mehdiag2r/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/exception-for-api/#post-15053672)
 * Status: resolved