Skip to content
Docs
Get RestroPress

Filter

rp_api_auth_error_message

Updated
On this page

Filters the error message returned when REST API authentication fails.

Used by the check_application_password_auth permission callbacks of the cart, customer, others, posts, reports and terms controllers when the request is neither authenticated by an application password nor by a logged-in user with the required capability. The message is returned in a rest_forbidden error.

Parameters#

ParameterTypeDescription
$messagestringDefault message, 'Authentication failed. Please check your credentials.'.

Return value#

string. The error message.

Example#

function my_api_auth_message( $message ) {
	return __( 'Access denied.', 'my-textdomain' );
}
add_filter( 'rp_api_auth_error_message', 'my_api_auth_message' );

Source#

Applied in:

  • includes/rest-api/Controllers/Version1/class-rp-rest-cart-v1-controller.php (line 376), in RP_REST_Cart_V1_Controller::check_application_password_auth()
  • includes/rest-api/Controllers/Version1/class-rp-rest-customer-v1-controller.php (line 500), in RP_REST_Customer_v1_Controller::check_application_password_auth()
  • includes/rest-api/Controllers/Version1/class-rp-rest-others-v1-controller.php (line 86), in RP_REST_Others_V1_Controller::check_application_password_auth()
  • includes/rest-api/Controllers/Version1/class-rp-rest-posts-controller.php (line 90), in RP_REST_Posts_Controller::check_application_password_auth()
  • includes/rest-api/Controllers/Version1/class-rp-rest-reports-v1-controller.php (line 110), in RP_REST_Reports_v1_Controller::check_application_password_auth()
  • includes/rest-api/Controllers/Version1/class-rp-rest-terms-controller.php (line 90), in RP_REST_Terms_Controller::check_application_password_auth()

See also#

Was this page helpful?