WXP Restaurant Bookings: Rooms offers actions for each step of a hire, filters for the mails, the privacy text, the stylesheet and the rate limit, a shortcode and a template you can copy to your theme. All names start with wxp_rbr_. The hooks of WXP Restaurant Reservations itself are in Filter- and action hooks.
Shortcode #
[[wxp_restaurant_rooms spaces="Boardroom,Conference room" space="Boardroom"]]
| Parameter | Description |
|---|---|
spaces |
Limit the form to these spaces, by name, comma separated. Without it, all spaces that have tables are shown. |
space |
The space that starts ticked. |
template |
The name of the template to render. |
The block Private space request form and the Elementor widget have the same options.
Actions #
Each action receives the hire.
| Hook | Fires when |
|---|---|
wxp_rbr_hire_requested |
A visitor sends a request. |
wxp_rbr_hire_confirmed |
A hire is confirmed. |
wxp_rbr_hire_declined |
A request is declined. |
wxp_rbr_hire_cancelled |
A hire is cancelled. |
wxp_rbr_hire_expired |
A request expires without an answer. |
add_action( 'wxp_rbr_hire_confirmed', function ( $hire ) {
// For example: tell your own system about the hire.
} );
Filters #
| Hook | What it changes |
|---|---|
wxp_rbr_receipt_mail |
The receipt mail to the visitor. |
wxp_rbr_answer_mail |
The mail to the visitor when you confirm, decline or cancel, or when a request expires. Arguments: the message, the type and the hire. |
wxp_rbr_notice_email |
The address that gets the notice of a new request. Default: the admin address of the site. Arguments: the address and the hire. |
wxp_rbr_consent_text |
The text next to the consent checkbox of the request form. |
wxp_rbr_load_css |
Return false to load no stylesheet. |
wxp_rbr_rate_limit |
The limit of a public route. Receives an array of the requests allowed and the window in seconds, and the action (taken or request). A limit of 0 turns it off. |
wxp_rbr_client_ip |
The address that is rate limited. Use it for sites behind a proxy. |
wxp_rbr_table_prefix |
The prefix of the tables of the add-on. Default: the WordPress prefix plus wxp_rbr_. |
// A shorter text for the consent checkbox.
add_filter( 'wxp_rbr_consent_text', function () {
return 'I agree that you store my details to handle this request.';
} );
// Behind a proxy: use the forwarded address.
add_filter( 'wxp_rbr_client_ip', function ( $ip ) {
return $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $ip;
} );
If you use the forwarded address, make sure your proxy sets it, because a visitor can fake the header otherwise.
Change the form #
Copy templates/rooms-request-form.html.twig from the plugin to wp-content/themes/your-theme/wxp-restaurant-reservations/rooms-request-form.html.twig. Keep the data-wxp-rbr-* attributes: the script finds its parts with them. See Twig templates for how templates are looked for.
The colours are CSS custom properties:
.wxp-rbr { --wxp-rbr-accent: #b45309; }
Good to know #
- Jobs: an hourly job (
wxp_rbr_expire) lets go of the space of every request whose hold ran out, and a job (wxp_rbr_retention) makes old hires anonymous. Deactivating the add-on stops them. - Privacy: the hires are part of the WordPress tools “Export personal data” and “Erase personal data”. A hire that is still going on is not erased. After the retention period you set for the reservations, the hires are made anonymous too: the space, the days and the number of people stay. A suggested text for your privacy policy is added.
- Uninstall: deleting the plugin removes nothing, unless Delete all data when the plugin is deleted of WXP Restaurant Reservations is on. Then the tables and settings of the add-on go, and so do the holds on the tables of the spaces.
- Demo data: with the WXP Agency Kit,
wp wxp-data import roomsadds three spaces and six hires in different states, andwp wxp-data remove roomsremoves exactly that. - Needs WXP Restaurant Reservations 0.11.1 or newer.