rest_authentication_errors WordPress Filter Hook

The rest_authentication_errors hook is used to add authentication errors to the WordPress REST API. This hook is called when the user is not authenticated and returns an error.

apply_filters( 'rest_authentication_errors', WP_Error|null|true $errors ) #

Filters REST API authentication errors.


Description

This is used to pass a WP_Error from an authentication method back to the API.

Authentication methods should check first if they’re being used, as multiple authentication methods can be enabled on a site (cookies, HTTP basic auth, OAuth). If the authentication method hooked in is not actually being attempted, null should be returned to indicate another authentication method should check instead. Similarly, callbacks should ensure the value is null before checking for errors.

A WP_Error instance can be returned if an error occurs, and this should match the format used by API methods internally (that is, the status data should be used). A callback can return true to indicate that the authentication method was used, and it succeeded.


Top ↑

Parameters

$errors

(WP_Error|null|true)WP_Error if authentication error, null if authentication method wasn't used, true if authentication succeeded.


Top ↑

Source

File: wp-includes/rest-api/class-wp-rest-server.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.4.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.