W3cubDocs

/WordPress

rest_authorization_required_code(): int

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

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

Changelog

Version Description
4.7.0 Introduced.

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