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.

Source

File: wp-includes/rest-api.php

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

Changelog

Version Description
4.7.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_authorization_required_code