Skip to content
Docs
Get RestroPress

Filter

rpress_errors

Updated
On this page

Filters the errors stored in the session before they are returned.

Runs every time rpress_get_errors reads the rpress_errors value from the RestroPress session, including when rpress_set_error adds a new error. The value is an array keyed by error ID with the message as value, or an empty value when no errors exist. Callbacks should handle a non-array value.

Parameters#

ParameterTypeDescription
$errorsarray|mixedErrors keyed by error ID with the message as value, or an empty value when none are stored.

Return value#

array|mixed. The errors to return.

Example#

function my_filter_errors( $errors ) {
	if ( is_array( $errors ) ) {
		foreach ( $errors as $error_id => $message ) {
			$errors[ $error_id ] = wp_strip_all_tags( $message );
		}
	}
	return $errors;
}
add_filter( 'rpress_errors', 'my_filter_errors', 10, 1 );

Notes#

rpress_set_error calls rpress_get_errors before adding its error, so this filter also runs on every set operation.

Source#

Applied in:

  • includes/error-tracking.php (line 56), in rpress_get_errors()

See also#

Was this page helpful?