rest_authorization_required_code

Returns a contextual HTTP error code for authorization failure.

Description

(integer) rest_authorization_required_code(); 

Returns (integer)

401 if the user is not logged in, 403 if the user is logged in.


Usage

  1. if ( !function_exists( 'rest_authorization_required_code' ) ) { 
  2. require_once ABSPATH . WPINC . '/rest-api.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = rest_authorization_required_code(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/rest-api.php  
  1. function rest_authorization_required_code() { 
  2. return is_user_logged_in() ? 403 : 401;