Filter
rpress_reservation_validation_errors
On this page
Filters the validation errors for a reservation.
Runs at the end of rpress_reservation_validate(), after the core checks for name, email, phone, party size, date and slot. Add errors to the WP_Error object to reject the reservation; the keys are shown against the matching form fields. When no errors remain, the sanitized core data is used. Because the raw input is passed, extension fields posted through rpress_reservation_submit_data can be validated here.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$errors | WP_Error | Errors collected so far, keyed by field name. |
$data | array | Sanitized core fields: date, slot, party, name, phone, email and note. |
$input | array | Raw input, including extension fields. |
Return value#
WP_Error. The error object; add errors to reject the reservation.
Example#
function my_reservation_validation_errors( $errors, $data, $input ) {
if ( 'outdoor' === ( $input['my_seating'] ?? '' ) && $data['party'] > 8 ) {
$errors->add( 'party', __( 'Outdoor seating is limited to 8 guests.', 'my-plugin' ) );
}
return $errors;
}
add_filter( 'rpress_reservation_validation_errors', 'my_reservation_validation_errors', 10, 3 );
Notes#
Also runs when a reservation is inserted programmatically with validation on, so $input may not come from the public form.
Source#
Applied in:
includes/features/reservations/functions.php(line 450), inrpress_reservation_validate()
See also#
Was this page helpful?
