WP_REST_Server::check_authentication(): WP_Error|null|true
- Since
- 4.4.0
- Source
wp-includes/rest-api/class-wp-rest-server.php:172
Checks the authentication headers if supplied.
Return
WP_Error|null|true- WP_Error indicates unsuccessful login, null indicates successful or no authentication provided
Hooks fired · 1
One hook fires while WP_REST_Server::check_authentication() runs, in this order:
- apply_filters( rest_authentication_errors )filterline 197 (+25 into the body)
Filters REST API authentication errors.
Uses · 1
- apply_filters()Calls the callback functions that have been added to a filter hook.
Used by · 1
- WP_REST_Server::serve_request()Handles serving a REST API request.
Source
public function check_authentication() { /** * Filters REST API authentication errors. * * 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. * * @since 4.4.0 * * @param WP_Error|null|true $errors WP_Error if authentication error, null if authentication * method wasn't used, true if authentication succeeded. */ return apply_filters( 'rest_authentication_errors', null ); }History
Introduced in 4.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/rest-api/class-wp-rest-server.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.