rest_authorization_required_code()WP 4.7.0

Returns a contextual HTTP error code for authorization failure.

No Hooks.

Return

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

Usage

rest_authorization_required_code();

Changelog

Since 4.7.0 Introduced.

rest_authorization_required_code() code WP 6.6.2

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