rest_authorization_required_code() WordPress Function

The rest_authorization_required_code() function is used to require authentication for all REST API requests. This function is used to ensure that only authorized users can access the API.

rest_authorization_required_code() #

Returns a contextual HTTP error code for authorization failure.


Return

(int) 401 if the user is not logged in, 403 if the user is logged in.


Top ↑

Source

File: wp-includes/rest-api.php

function rest_authorization_required_code() {
	return is_user_logged_in() ? 403 : 401;
}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More