Skip to content
Docs
Get RestroPress

Function

Reservations functions

Updated
On this page

Functions for table reservations: slots and capacity, creating and confirming reservations, the booking form and the reservation emails.

88 functions. Each entry shows the signature, parameters, return value and where it is defined. Functions marked internal are hook callbacks, screen renderers and other plumbing that extensions normally do not call.

rpress_reservation_get_user_reservations()#

Returns the reservations that belong to a user.

Matches reservations booked while logged in as the user (_rpress_res_user) or made with the user's account email (_rpress_res_email). Returns up to 50 published reservations, latest reservation time first. The limit is filterable with rpress_reservation_account_limit.

rpress_reservation_get_user_reservations( $user_id )

Parameters

ParameterTypeDefaultDescription
$user_idintRequiredUser ID.

Returns array: List of reservations in the format of rpress_get_reservation(). Empty when the user does not exist.

Example

$reservations = rpress_reservation_get_user_reservations( get_current_user_id() );
foreach ( $reservations as $res ) {
	echo esc_html( rpress_reservation_format_date( $res['ts'] ) ) . "\n";
}

Defined in includes/features/reservations/account.php, line 20.

rpress_reservation_account_url()#

Returns the URL of the Reservations section in the customer dashboard.

Finds the oldest published page containing the [customer_dashboard shortcode, caches it in the rpress_customer_dashboard_page transient for a day, and adds the rpress_account=reservations query argument and the section hash. Filterable with rpress_reservation_account_url.

rpress_reservation_account_url()

Returns string: URL, or an empty string when no dashboard page exists.

Defined in includes/features/reservations/account.php, line 53.

rpress_reservation_remember_account_section()#

Opens the Reservations dashboard tab for links that carry rpress_account=reservations.

Hooked to template_redirect. Sets the nav_location cookie for five minutes so a customer who has to log in first still lands on the Reservations section.

rpress_reservation_remember_account_section()

Internal. Defined in includes/features/reservations/account.php, line 79.

rpress_reservation_booking_page_url()#

Returns the permalink of the reservation booking page.

Uses rpress_reservation_booking_page_id(). Filterable with rpress_reservation_booking_page_url.

rpress_reservation_booking_page_url()

Returns string: URL, or an empty string when there is no booking page.

Example

$url = rpress_reservation_booking_page_url();

Defined in includes/features/reservations/account.php, line 95.

rpress_reservation_account_menu_item()#

Outputs the Reservations item in the customer dashboard sidebar.

Hooked to rpress_user_dashboard_menu_items. Shown when the current user has reservations or the site has a booking page.

rpress_reservation_account_menu_item()

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/account.php, line 108.

rpress_reservation_account_panel()#

Outputs the Reservations panel of the customer dashboard.

Hooked to rpress_user_dashboard_panels. Lists the user's upcoming reservations (soonest first) and past ones with date, time, guests and status. Shows a book-a-table link when the user has none and a booking page exists. Outputs nothing when there are no reservations and no booking page.

rpress_reservation_account_panel()

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/account.php, line 132.

Replaces the email footer link while a reservation email is being sent.

Adds filters on rpress_email_footer_text and rpress_email_show_footer_link. Admin emails link to the reservation in wp-admin; customer emails link to the dashboard Reservations section when the customer has an account.

rpress_reservation_email_footer_filter( $id, $type )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.
$typestringRequiredEmail type.

Returns callable: The footer text filter, so the caller can remove it after sending.

Note: The caller must remove both filters after sending, as rpress_reservation_send_email() does.

Internal. Defined in includes/features/reservations/account.php, line 243.

rpress_reservation_is_list_screen()#

Checks whether the current admin screen is the reservations list.

rpress_reservation_is_list_screen()

Returns bool: True on the list screen.

Note: Needs the admin screen to be set, so call it after current_screen.

Internal. Defined in includes/features/reservations/admin.php, line 19.

rpress_reservation_columns()#

Defines the columns of the reservations list.

Filter callback on manage_rpress_reservation_posts_columns.

rpress_reservation_columns( $columns )

Parameters

ParameterTypeDefaultDescription
$columnsarrayRequiredExisting columns.

Returns array: Columns: checkbox, date and time, name, guests, phone, email and status.

Internal. Defined in includes/features/reservations/admin.php, line 31.

rpress_reservation_sortable_columns()#

Makes the Date / Time column of the reservations list sortable.

rpress_reservation_sortable_columns( $columns )

Parameters

ParameterTypeDefaultDescription
$columnsarrayRequiredSortable columns.

Returns array: The columns with rpress_res_when added.

Internal. Defined in includes/features/reservations/admin.php, line 51.

rpress_reservation_column_content()#

Outputs the cell content of a reservations list column.

Handles the date and time, guests, phone, email and status columns.

rpress_reservation_column_content( $column, $post_id )

Parameters

ParameterTypeDefaultDescription
$columnstringRequiredColumn key.
$post_idintRequiredReservation ID.

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/admin.php, line 65.

rpress_reservation_status_url()#

Builds the nonce-protected admin URL that changes a reservation's status.

Points to admin-post.php with the rpress_reservation_status action, handled by rpress_reservation_handle_status_action().

rpress_reservation_status_url( $id, $status )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.
$statusstringRequiredTarget status slug.

Returns string: URL with a nonce.

Internal. Defined in includes/features/reservations/admin.php, line 113.

rpress_reservation_row_actions()#

Adds status action links to the rows of the reservations list.

Pending reservations get Confirm and Decline, confirmed get Complete and Cancel, declined and cancelled get Confirm. Removes quick edit. Nothing is added for trashed rows or users who cannot edit the reservation.

rpress_reservation_row_actions( $actions, $post )

Parameters

ParameterTypeDefaultDescription
$actionsarrayRequiredRow actions.
$postWP_PostRequiredThe reservation post.

Returns array: The row actions.

Internal. Defined in includes/features/reservations/admin.php, line 135.

rpress_reservation_handle_status_action()#

Handles the admin-post request that changes one reservation's status.

Checks the nonce and the edit_post capability, calls rpress_set_reservation_status() and redirects back with the result in the query string. Ends the request.

rpress_reservation_handle_status_action()

Note: Calls exit after redirecting.

Internal. Defined in includes/features/reservations/admin.php, line 177.

rpress_reservation_bulk_actions()#

Adds status bulk actions to the reservations list.

Adds Confirm, Decline, Mark completed and Cancel, and removes the bulk edit action.

rpress_reservation_bulk_actions( $actions )

Parameters

ParameterTypeDefaultDescription
$actionsarrayRequiredBulk actions.

Returns array: The bulk actions.

Internal. Defined in includes/features/reservations/admin.php, line 200.

rpress_reservation_handle_bulk_actions()#

Applies a bulk status action to the selected reservations.

Handles actions prefixed rpress_res_, changes the status of each reservation the user can edit with rpress_set_reservation_status() and adds the result counts to the redirect URL.

rpress_reservation_handle_bulk_actions( $redirect, $action, $ids )

Parameters

ParameterTypeDefaultDescription
$redirectstringRequiredRedirect URL.
$actionstringRequiredBulk action.
$idsarrayRequiredSelected post IDs.

Returns string: The redirect URL, with rpress_res_updated and rpress_res_count added for reservation actions.

Internal. Defined in includes/features/reservations/admin.php, line 223.

rpress_reservation_admin_notices()#

Shows the result notice after a reservation status change.

Only on the reservations list and edit screens, and only when rpress_res_updated is in the query string.

rpress_reservation_admin_notices()

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/admin.php, line 244.

rpress_reservation_table_booking_notice()#

Shows a dismissible notice about the Table Booking extension on the reservations list.

Shown to users with the manage_shop_settings capability unless the extension is active or the user dismissed it, which is stored in the rpress_res_tb_notice_dismissed user meta.

rpress_reservation_table_booking_notice()

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/admin.php, line 278.

rpress_reservation_views()#

Adds the Today, Upcoming, Needs action and Past views to the reservations list.

Filter callback on views_edit-rpress_reservation. Rewrites the All view link and removes the Published view.

rpress_reservation_views( $views )

Parameters

ParameterTypeDefaultDescription
$viewsarrayRequiredList table views.

Returns array: The views.

Internal. Defined in includes/features/reservations/admin.php, line 306.

rpress_reservation_landing_view()#

Redirects the unfiltered reservations list to Needs action while requests are waiting.

Hooked to load-edit.php. Redirects only when no query arguments other than the post type are set and there are pending upcoming reservations.

rpress_reservation_landing_view()

Note: Calls exit after redirecting.

Internal. Defined in includes/features/reservations/admin.php, line 349.

rpress_reservation_list_filters()#

Outputs the status and date filters above the reservations list.

Hooked to restrict_manage_posts. Does nothing for other post types.

rpress_reservation_list_filters( $post_type )

Parameters

ParameterTypeDefaultDescription
$post_typestringRequiredPost type of the list.

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/admin.php, line 376.

rpress_reservation_disable_months()#

Hides the months dropdown on the reservations list.

rpress_reservation_disable_months( $disable, $post_type )

Parameters

ParameterTypeDefaultDescription
$disableboolRequiredWhether to disable the dropdown.
$post_typestringRequiredPost type.

Returns bool: True for reservations, otherwise the original value.

Internal. Defined in includes/features/reservations/admin.php, line 407.

rpress_reservation_list_query()#

Applies the views, filters and ordering to the reservations list query.

Hooked to pre_get_posts. Handles the rpress_res_view, rpress_res_status and rpress_res_date query arguments with meta queries and orders by reservation time. The unfiltered list shows the newest bookings first.

rpress_reservation_list_query( $query )

Parameters

ParameterTypeDefaultDescription
$queryWP_QueryRequiredThe query.

Internal. Defined in includes/features/reservations/admin.php, line 419.

rpress_reservation_meta_boxes()#

Registers the Reservation details meta box on the edit screen.

rpress_reservation_meta_boxes()

Internal. Defined in includes/features/reservations/admin.php, line 485.

rpress_reservation_details_box()#

Outputs the Reservation details meta box.

Shows date, time, guests, name, phone, email, note, status and a notify checkbox. Fires rpress_reservation_admin_details so extensions can add rows. Reservations entered here are not limited by slot capacity or opening hours.

rpress_reservation_details_box( $post )

Parameters

ParameterTypeDefaultDescription
$postWP_PostRequiredThe reservation post.

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/admin.php, line 497.

rpress_reservation_insert_post_data()#

Uses the guest name as the reservation post title when saving from the edit screen.

Filter callback on wp_insert_post_data. Requires a valid details box nonce. Also publishes drafts and auto-drafts.

rpress_reservation_insert_post_data( $data, $postarr )

Parameters

ParameterTypeDefaultDescription
$dataarrayRequiredPost data.
$postarrarrayRequiredRaw post array.

Returns array: The post data.

Internal. Defined in includes/features/reservations/admin.php, line 546.

rpress_reservation_save_details()#

Saves the Reservation details meta box.

Checks nonce and capability, validates the date and time, fires rpress_reservation_admin_save, then updates the _rpress_res_* meta. For a new reservation it sets the status and source admin and fires rpress_reservation_created. For an existing one it reschedules the reminder when the time changed and applies the status through rpress_set_reservation_status().

rpress_reservation_save_details( $post_id )

Parameters

ParameterTypeDefaultDescription
$post_idintRequiredPost ID.

Internal. Defined in includes/features/reservations/admin.php, line 571.

rpress_reservation_admin_styles()#

Prints small CSS rules for the reservation list and edit screens.

rpress_reservation_admin_styles()

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/admin.php, line 638.

rpress_reservation_edit_screen_tweaks()#

Hides the visibility and scheduling clutter in the Publish box of the reservation edit screen.

rpress_reservation_edit_screen_tweaks()

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/admin.php, line 671.

rpress_reservation_email_defaults()#

Returns the default label, subject and body of each reservation email type.

Types are received, confirmed, declined, reminder and admin. Owners override the subject and body in the reservation email settings. Filterable with rpress_reservation_email_defaults.

rpress_reservation_email_defaults()

Returns array: Associative array of type => array with keys label, subject and body.

Defined in includes/features/reservations/emails.php, line 23.

rpress_reservation_email_tags()#

Replaces reservation tags such as {name} and {date} in a string.

Supported tags are {name}, {phone}, {email}, {note}, {party_size}, {date}, {time}, {status}, {reservation_id}, {sitename} and {admin_link}. Values can be changed with the rpress_reservation_email_tag_values filter.

rpress_reservation_email_tags( $text, $res, $html = true )

Parameters

ParameterTypeDefaultDescription
$textstringRequiredText containing tags.
$resarrayRequiredReservation as returned by rpress_get_reservation().
$htmlbooltrueEscape the values with esc_html() before substitution.

Returns string: The text with tags replaced.

Example

$res  = rpress_get_reservation( 45 );
$text = rpress_reservation_email_tags( 'Hello {name}, table for {party_size}.', $res );

Defined in includes/features/reservations/emails.php, line 65.

rpress_reservation_send_email()#

Sends one reservation email through the store's email template.

Customer types go to the reservation email; the admin type goes to the store admin notice addresses with the customer as Reply-To. Uses the saved subject and body, falling back to the defaults. Can be cancelled with the rpress_reservation_send_email filter. Headers are filterable with rpress_reservation_email_headers. Fires rpress_reservation_email_sent afterwards.

rpress_reservation_send_email( $id, $type )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.
$typestringRequiredOne of received, confirmed, declined, reminder or admin.

Returns bool: True when the email was sent; false for an unknown reservation or type, no recipient, a filter veto or a send failure.

Example

rpress_reservation_send_email( 45, 'confirmed' );

Note: Does not check the reservation status or whether a reminder was already sent.

Defined in includes/features/reservations/emails.php, line 95.

rpress_reservation_created_emails()#

Emails the customer and the admin when a reservation is created.

Hooked to rpress_reservation_created. Sends the confirmed email when the reservation starts confirmed, otherwise the received email. Skips everything when the insert arguments contain a false notify. The admin email is skipped when it is turned off or the source is admin.

rpress_reservation_created_emails( $id, $status, $args = array() )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.
$statusstringRequiredInitial status.
$argsarrayarray()Insert arguments.

Internal. Defined in includes/features/reservations/emails.php, line 153.

rpress_reservation_status_emails()#

Emails the customer when a reservation is confirmed or declined.

Hooked to rpress_reservation_status_changed. Sends only when $notify is true and the new status is confirmed or declined.

rpress_reservation_status_emails( $id, $status, $old, $notify )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.
$statusstringRequiredNew status.
$oldstringRequiredPrevious status.
$notifyboolRequiredWhether emails should be sent.

Internal. Defined in includes/features/reservations/emails.php, line 174.

rpress_reservation_send_reminder()#

Cron callback that sends the reservation reminder once.

Hooked to rpress_reservation_reminder. Sends only for published, confirmed reservations that are still in the future and not yet reminded, then stores the time in _rpress_res_reminded.

rpress_reservation_send_reminder( $id )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.

Internal. Defined in includes/features/reservations/emails.php, line 188.

rpress_reservation_register_assets()#

Registers the reservation form styles, scripts and block.

Hooked to init at priority 20. Registers the rpress-reservation style and script, the block editor script and the rpress/reservation-form block with rpress_reservation_render_block() as its render callback.

rpress_reservation_register_assets()

Internal. Defined in includes/features/reservations/frontend.php, line 22.

rpress_reservation_render_block()#

Renders the Table Reservation block.

Wraps the output of rpress_reservation_shortcode() in the block wrapper, passing the block title attribute.

rpress_reservation_render_block( $attributes = array() )

Parameters

ParameterTypeDefaultDescription
$attributesarrayarray()Block attributes.

Returns string: Block HTML.

Internal. Defined in includes/features/reservations/frontend.php, line 68.

rpress_reservation_request_result()#

Stores or returns the result of a form submission handled in this request.

Holds the errors and sticky values so the shortcode can redisplay the form. Pass an array to set the result, or null to read it.

rpress_reservation_request_result( $set = null )

Parameters

ParameterTypeDefaultDescription
$setarray|nullnullResult to store.

Returns array: The stored result, with keys errors (WP_Error) and values (array) after a failed submission, otherwise empty.

Internal. Defined in includes/features/reservations/frontend.php, line 81.

rpress_reservation_rate_limit_state()#

Returns the per-IP reservation submission counter and limit.

The count is kept in a transient keyed by the client IP. The limit is 5 by default, filterable with rpress_reservation_rate_limit.

rpress_reservation_rate_limit_state()

Returns array: Array with keys key (transient name), count (int) and limit (int).

Internal. Defined in includes/features/reservations/frontend.php, line 95.

rpress_reservation_handle_submit()#

Handles a booking form POST and redirects on success.

Hooked to template_redirect. Checks the honeypot, nonce, paused setting and rate limit, applies the rpress_reservation_submit_data filter, then calls rpress_insert_reservation(). On success it increments the rate limit and redirects with rpress_reservation=received (filterable with rpress_reservation_submit_redirect). On failure it stores the errors for the form.

rpress_reservation_handle_submit()

Note: Calls exit after redirecting. Users with the edit_shop_payments capability are exempt from the rate limit.

Internal. Defined in includes/features/reservations/frontend.php, line 110.

rpress_reservation_view_key()#

Returns the key that lets the success screen show a reservation summary.

A hash of the reservation ID and its email, shortened to 20 characters.

rpress_reservation_view_key( $id )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.

Returns string: The key.

Internal. Defined in includes/features/reservations/frontend.php, line 223.

rpress_reservation_ajax_slots()#

AJAX handler that returns the available slots for a date and party size.

Registered for the rpress_reservation_slots action, logged in and logged out. Reads date and party from the query string and sends a JSON success response with each slot's ts, label and available.

rpress_reservation_ajax_slots()

Note: Public read-only lookup with no nonce.

Internal. Defined in includes/features/reservations/frontend.php, line 233.

rpress_reservation_maybe_enqueue()#

Enqueues the reservation form assets on pages that contain the form.

Checks the current post for the rpress_reservation shortcode or the rpress/reservation-form block.

rpress_reservation_maybe_enqueue()

Internal. Defined in includes/features/reservations/frontend.php, line 259.

rpress_reservation_shortcode()#

Renders the reservation booking form for the [rpress_reservation] shortcode.

Accepts a title attribute. Shows the success screen after a submission, a paused message when reservations are paused, or the form. Filters: rpress_reservation_success_message and rpress_reservation_success_summary; the form fires rpress_reservation_form_after_time.

rpress_reservation_shortcode( $atts = array() )

Parameters

ParameterTypeDefaultDescription
$attsarrayarray()Shortcode attributes.

Returns string: The HTML.

Example

echo do_shortcode( '[rpress_reservation title="Book a table"]' );

Note: Returns the output instead of echoing it.

Defined in includes/features/reservations/frontend.php, line 275.

rpress_reservation_live_orders_notice()#

Outputs a count of today's remaining reservations on the Live Orders screen.

Hooked to rpress_payments_page_top. Shown only to users with edit_shop_payments when at least one active reservation is still to come today.

rpress_reservation_live_orders_notice()

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/frontend.php, line 469.

rpress_reservation_int_setting()#

Returns an integer reservation setting with a default and a minimum.

Reads the stored option directly from the $rpress_options global, because rpress_get_option() treats 0 as empty and 0 is valid for lead time. Non-numeric or empty values fall back to the default. The value passes through the rpress_reservation_setting_{$key} filter and is then raised to the minimum.

rpress_reservation_int_setting( $key, $default, $min = 0 )

Parameters

ParameterTypeDefaultDescription
$keystringRequiredSetting ID.
$defaultintRequiredValue used when the setting is not stored or not numeric.
$minint0Lowest value allowed.

Returns int: The resolved value, never below $min.

Internal. Defined in includes/features/reservations/functions.php, line 25.

rpress_reservation_settings()#

Returns all reservation settings resolved with their defaults.

The array passes through the rpress_reservation_settings filter. Defaults are a 30 minute interval, capacity 20 per slot, a maximum party of 10, a 60 minute lead time, 30 days ahead and reminders 3 hours before.

rpress_reservation_settings()

Returns array: Array with keys interval, capacity, max_party, lead_time, max_days, reminder_hours (ints), and reminders, auto_confirm, paused (bools).

Example

$settings = rpress_reservation_settings();
echo (int) $settings['max_party'];

Defined in includes/features/reservations/functions.php, line 41.

rpress_reservation_statuses()#

Returns the reservation statuses as slug and label pairs.

Defaults are pending, confirmed, declined, cancelled and completed. Extensions can add statuses with the rpress_reservation_statuses filter.

rpress_reservation_statuses()

Returns array: Associative array of status slug => translated label.

Example

foreach ( rpress_reservation_statuses() as $slug => $label ) {
	echo esc_html( $slug . ': ' . $label ) . "\n";
}

Defined in includes/features/reservations/functions.php, line 64.

rpress_reservation_active_statuses()#

Returns the statuses that hold seats and count against slot capacity.

Defaults to pending and confirmed. Filterable with rpress_reservation_active_statuses, for example to hold seats for an awaiting-payment status.

rpress_reservation_active_statuses()

Returns array: List of status slugs.

Defined in includes/features/reservations/functions.php, line 83.

rpress_reservation_has_table_booking()#

Checks whether the Table Booking extension is active.

True when the RP_TB_VERSION constant is defined or the RP_Tablebooking class exists. Used to hide the extension upsell. Filterable with rpress_reservation_has_table_booking.

rpress_reservation_has_table_booking()

Returns bool: True when Table Booking is active.

Internal. Defined in includes/features/reservations/functions.php, line 93.

rpress_reservation_table_booking_url()#

Returns the store page URL of the Table Booking extension.

rpress_reservation_table_booking_url()

Returns string: Absolute URL on restropress.com.

Internal. Defined in includes/features/reservations/functions.php, line 103.

rpress_reservation_is_valid_date()#

Checks whether a string is a real date in Y-m-d format.

Requires four-digit year, two-digit month and day, and the date must exist on the calendar (checked with checkdate).

rpress_reservation_is_valid_date( $date )

Parameters

ParameterTypeDefaultDescription
$datestringRequiredDate string to test.

Returns bool: True for a valid Y-m-d date; false otherwise, including non-string values.

Example

if ( rpress_reservation_is_valid_date( '2027-02-29' ) ) {
	// Not reached: 2027 is not a leap year.
}

Defined in includes/features/reservations/functions.php, line 114.

rpress_reservation_date_window()#

Returns today and the last bookable date in the store timezone.

The last date is today plus the max_days reservation setting.

rpress_reservation_date_window()

Returns array: Array with keys today and last, both Y-m-d strings.

Example

$window = rpress_reservation_date_window();
echo $window['today'] . ' to ' . $window['last'];

Defined in includes/features/reservations/functions.php, line 127.

rpress_reservation_format_time()#

Formats a timestamp as a time using the store's time format.

The store_time_format RestroPress option overrides the WordPress time format: 24hrs gives H:i and 12hrs gives g:i a. Output is in the site timezone.

rpress_reservation_format_time( $ts )

Parameters

ParameterTypeDefaultDescription
$tsintRequiredUnix timestamp.

Returns string: Formatted time.

Defined in includes/features/reservations/functions.php, line 143.

rpress_reservation_format_date()#

Formats a timestamp as a date using the WordPress date format.

Output is in the site timezone.

rpress_reservation_format_date( $ts )

Parameters

ParameterTypeDefaultDescription
$tsintRequiredUnix timestamp.

Returns string: Formatted date.

Defined in includes/features/reservations/functions.php, line 161.

rpress_reservation_covers_by_slot()#

Returns the number of guests already held per slot timestamp within a range.

Sums the party size of published reservations whose _rpress_res_status is one of the active statuses and whose _rpress_res_ts falls in the range. Use $exclude_id to leave out the reservation being edited.

rpress_reservation_covers_by_slot( $from_ts, $to_ts, $exclude_id = 0 )

Parameters

ParameterTypeDefaultDescription
$from_tsintRequiredRange start, inclusive.
$to_tsintRequiredRange end, inclusive.
$exclude_idint0Reservation ID to leave out.

Returns array: Associative array of slot timestamp => covers. Slots with no reservations are absent.

Example

$window = rpress_reservation_date_window();
$from   = rpress_get_wp_timestamp( $window['today'] . ' 00:00' );
$covers = rpress_reservation_covers_by_slot( $from, $from + DAY_IN_SECONDS );

Defined in includes/features/reservations/functions.php, line 174.

rpress_reservation_get_slots()#

Returns the bookable time slots for a date.

Slots start at the store's opening time every interval minutes, and the last one starts one interval before closing. Closed days, holidays, slots inside the lead time and dates outside the booking window return an empty array. Past-midnight closing times are handled. Filters: rpress_reservation_last_seating_offset, rpress_reservation_slot_capacity and rpress_reservation_slots.

rpress_reservation_get_slots( $date, $party = 1, $exclude_id = 0 )

Parameters

ParameterTypeDefaultDescription
$datestringRequiredDate in Y-m-d format.
$partyint1Party size, used to flag slots without enough room.
$exclude_idint0Reservation ID to leave out of the capacity counts.

Returns array: List of slots, each with ts (int), time (H:i string), label (formatted time), remaining (int seats left) and available (bool, true when remaining is at least the party size).

Example

$slots = rpress_reservation_get_slots( '2027-03-05', 4 );
foreach ( $slots as $slot ) {
	if ( $slot['available'] ) {
		echo esc_html( $slot['label'] ) . "\n";
	}
}

Defined in includes/features/reservations/functions.php, line 217.

rpress_reservation_first_open_date()#

Returns the first date from today that has an available slot.

Scans up to 14 days by default, filterable with rpress_reservation_first_open_scan_days, and stops at the end of the booking window. The result is cached in a transient for five minutes, keyed by date, party size and settings.

rpress_reservation_first_open_date( $party = 1 )

Parameters

ParameterTypeDefaultDescription
$partyint1Party size.

Returns string: Date in Y-m-d format, or today when no slot is open in the scanned range.

Example

$date = rpress_reservation_first_open_date( 2 );

Defined in includes/features/reservations/functions.php, line 275.

rpress_reservation_client_ip()#

Returns the client IP address used for the submission rate limit.

Reads REMOTE_ADDR only, because forwarded headers can be set by the client. Sites behind a trusted proxy can supply the real address with the rpress_reservation_client_ip filter.

rpress_reservation_client_ip()

Returns string: A valid IP address, or 0.0.0.0 when none is valid.

Internal. Defined in includes/features/reservations/functions.php, line 313.

rpress_reservation_acquire_lock()#

Takes a short per-date lock so a capacity check and insert cannot interleave.

The lock is a row in the options table created with INSERT IGNORE, which only one request can create. It retries up to 15 times, 0.2 seconds apart, and clears a lock older than 10 seconds once as stale.

rpress_reservation_acquire_lock( $key )

Parameters

ParameterTypeDefaultDescription
$keystringRequiredLock key, normally the booking date.

Returns string|false: Option name to pass to rpress_reservation_release_lock(), or false when the lock is still busy.

Note: Always release the lock, preferably in a finally block.

Internal. Defined in includes/features/reservations/functions.php, line 330.

rpress_reservation_release_lock()#

Releases a lock taken with rpress_reservation_acquire_lock().

Deletes the lock row from the options table. Does nothing for a false or empty value.

rpress_reservation_release_lock( $name )

Parameters

ParameterTypeDefaultDescription
$namestring|falseRequiredOption name returned by rpress_reservation_acquire_lock().

Internal. Defined in includes/features/reservations/functions.php, line 360.

rpress_reservation_validate()#

Validates and normalises reservation input.

Sanitizes the fields, then checks name, email, phone, party size, date window, whether the date has slots, and that the chosen slot exists and has room for the party. The rpress_reservation_validation_errors filter can add errors. Pass $exclude_id when editing so the reservation does not count against its own slot.

rpress_reservation_validate( $input, $exclude_id = 0 )

Parameters

ParameterTypeDefaultDescription
$inputarrayRequiredRaw input with keys date (Y-m-d), slot (slot timestamp), party, name, phone, email and note.
$exclude_idint0Reservation being edited, left out of capacity checks.

Returns array|WP_Error: Clean data with the same keys as the input, or a WP_Error whose error codes are the field names (name, email, phone, party, date, slot).

Example

$data = rpress_reservation_validate( array(
	'date'  => '2027-03-05',
	'slot'  => 1804000000,
	'party' => 2,
	'name'  => 'Sam Taylor',
	'phone' => '555 0100',
	'email' => 'sam@example.com',
) );
if ( is_wp_error( $data ) ) {
	echo esc_html( implode( ' ', $data->get_error_messages() ) );
}

Note: The slot value must be a timestamp returned by rpress_reservation_get_slots().

Defined in includes/features/reservations/functions.php, line 376.

rpress_insert_reservation()#

Creates a reservation.

Takes a per-date lock, validates the input unless disabled, stores the reservation as an rpress_reservation post with _rpress_res_* meta, then fires rpress_reservation_created. The initial status comes from status, otherwise confirmed when auto-confirm is on or pending. It can be changed with the rpress_reservation_initial_status filter. The rpress_reservation_insert_meta action runs while the lock is held.

rpress_insert_reservation( $input, $args = array() )

Parameters

ParameterTypeDefaultDescription
$inputarrayRequiredRaw input, see rpress_reservation_validate().
$argsarrayarray()Options: validate (bool, default true), status (status slug, default empty for automatic) and source (string, default 'web').

Returns int|WP_Error: The new reservation ID, or a WP_Error when validation fails, the date lock is busy or the post cannot be inserted.

Example

$id = rpress_insert_reservation(
	array(
		'date'  => '2027-03-05',
		'slot'  => 1804000000,
		'party' => 2,
		'name'  => 'Sam Taylor',
		'phone' => '555 0100',
		'email' => 'sam@example.com',
	),
	array( 'source' => 'phone' )
);
if ( is_wp_error( $id ) ) {
	echo esc_html( $id->get_error_message() );
}

Note: Only source web records the client IP and the logged-in user on the reservation. With validate set to false the input is stored as given, so it must already be clean.

Defined in includes/features/reservations/functions.php, line 465.

rpress_reservation_insert_locked()#

Runs the validation, status choice and insert while the date lock is held.

Called by rpress_insert_reservation(). Applies the rpress_reservation_initial_status filter, creates the post, saves the _rpress_res_* meta and fires rpress_reservation_insert_meta so extensions can save their data and assign tables without racing another booking.

rpress_reservation_insert_locked( $input, $args )

Parameters

ParameterTypeDefaultDescription
$inputarrayRequiredRaw input.
$argsarrayRequiredParsed insert arguments with keys validate, status and source.

Returns int|WP_Error: The new reservation ID, or a WP_Error.

Note: Call rpress_insert_reservation() instead; this function does not take the lock itself.

Internal. Defined in includes/features/reservations/functions.php, line 513.

rpress_get_reservation()#

Returns a reservation as an array.

rpress_get_reservation( $id )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.

Returns array|false: Array with keys id, ts, date, party, name, phone, email, note and status, or false when the ID is not a reservation.

Example

$res = rpress_get_reservation( 45 );
if ( $res ) {
	echo esc_html( $res['name'] . ' (' . $res['party'] . ')' );
}

Defined in includes/features/reservations/functions.php, line 595.

rpress_get_reservation_status()#

Returns the current status slug of a reservation.

Falls back to pending when the stored value is missing or not a registered status.

rpress_get_reservation_status( $id )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.

Returns string: Status slug.

Example

$status = rpress_get_reservation_status( 45 );

Defined in includes/features/reservations/functions.php, line 621.

rpress_set_reservation_status()#

Changes a reservation's status.

Fails for an unknown status or reservation, or when the status is unchanged. Otherwise updates _rpress_res_status and fires rpress_reservation_status_changed with the new status, old status and notify flag. Customer emails and reminder scheduling hook into that action.

rpress_set_reservation_status( $id, $status, $notify = true )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.
$statusstringRequiredNew status slug.
$notifybooltrueWhether customer emails should go out for this change.

Returns bool: True when the status changed.

Example

rpress_set_reservation_status( 45, 'confirmed' );

Defined in includes/features/reservations/functions.php, line 635.

rpress_reservation_schedule_reminder()#

Schedules or clears the reminder event for a reservation.

Clears any existing event first. Schedules a single rpress_reservation_reminder event the configured number of hours before the reservation, only when the reservation is confirmed, reminders are enabled, no reminder was sent yet and the time is still in the future.

rpress_reservation_schedule_reminder( $id )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.

Returns int|false: Unix timestamp the reminder runs at, or false when none is scheduled.

Defined in includes/features/reservations/functions.php, line 665.

rpress_reservation_clear_reminder()#

Removes the pending reminder event of a reservation.

rpress_reservation_clear_reminder( $id )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.

Defined in includes/features/reservations/functions.php, line 688.

rpress_reservation_sync_reminder()#

Keeps the reminder event in step with a reservation's status.

Hooked to rpress_reservation_created and rpress_reservation_status_changed. Schedules the reminder for confirmed reservations and clears it for any other status.

rpress_reservation_sync_reminder( $id, $status )

Parameters

ParameterTypeDefaultDescription
$idintRequiredReservation ID.
$statusstringRequiredNew status slug.

Internal. Defined in includes/features/reservations/functions.php, line 700.

rpress_reservation_before_delete()#

Clears the reminder event when a reservation is deleted or trashed.

Hooked to before_delete_post and wp_trash_post. Ignores other post types.

rpress_reservation_before_delete( $post_id )

Parameters

ParameterTypeDefaultDescription
$post_idintRequiredPost ID.

Internal. Defined in includes/features/reservations/functions.php, line 717.

rpress_reservation_count_today()#

Counts today's reservations that hold seats.

Counts published reservations dated today in the store timezone with an active status. Optionally limited to those not yet started.

rpress_reservation_count_today( $upcoming_only = false )

Parameters

ParameterTypeDefaultDescription
$upcoming_onlyboolfalseCount only reservations at or after the current time.

Returns int: Number of reservations.

Example

$left_today = rpress_reservation_count_today( true );

Defined in includes/features/reservations/functions.php, line 732.

rpress_reservation_count_pending()#

Counts upcoming reservations still waiting to be confirmed or declined.

Counts published reservations with the pending status whose time has not passed. This is the Needs action count in the list and the number next to the menu item.

rpress_reservation_count_pending()

Returns int: Number of pending reservations.

Defined in includes/features/reservations/functions.php, line 760.

rpress_reservations_enabled()#

Checks whether table reservations are turned on.

Reads the enable_reservations option, which is off by default. Filterable with rpress_reservations_enabled.

rpress_reservations_enabled()

Returns bool: True when reservations are enabled.

Example

if ( function_exists( 'rpress_reservations_enabled' ) && rpress_reservations_enabled() ) {
	// Reservations are on.
}

Defined in includes/features/reservations/pages.php, line 23.

rpress_reservation_maybe_migrate_switch()#

Turns reservations on once for sites that already hold reservations.

Runs once per site, tracked by the rpress_reservations_switch_set option. If any rpress_reservation post exists, sets enable_reservations and, when empty, the reservation_page setting to a page found by content.

rpress_reservation_maybe_migrate_switch()

Internal. Defined in includes/features/reservations/pages.php, line 35.

rpress_reservation_find_booking_page()#

Finds the oldest published page that contains the booking form.

Searches page content for the [rpress_reservation] shortcode or the rpress/reservation-form block.

rpress_reservation_find_booking_page()

Returns int: Page ID, or 0 when none is found.

Internal. Defined in includes/features/reservations/pages.php, line 67.

rpress_reservation_is_live_page()#

Checks whether an ID belongs to a published page.

rpress_reservation_is_live_page( $page_id )

Parameters

ParameterTypeDefaultDescription
$page_idintRequiredPage ID.

Returns bool: True for a published page.

Internal. Defined in includes/features/reservations/pages.php, line 87.

rpress_reservation_booking_page_id()#

Returns the ID of the page where guests book a table.

Uses the reservation_page setting when it points at a published page. Otherwise searches page content for the form and caches the result in the rpress_reservation_booking_page transient for a day.

rpress_reservation_booking_page_id()

Returns int: Page ID, or 0 when none.

Example

$page_id = rpress_reservation_booking_page_id();
if ( $page_id ) {
	$url = get_permalink( $page_id );
}

Defined in includes/features/reservations/pages.php, line 99.

rpress_reservation_create_booking_page()#

Creates the Reserve a Table page, or reuses a page that already has the form.

A new page is published with the [rpress_reservation] shortcode. A transient records the new page so an admin notice can be shown.

rpress_reservation_create_booking_page()

Returns int: Page ID, or 0 when the page could not be created.

Internal. Defined in includes/features/reservations/pages.php, line 119.

rpress_reservation_settings_before_save()#

Ensures a booking page exists when reservations are turned on.

Filter callback on pre_update_option_rpress_settings. When enable_reservations changes from off to on and the reservation_page setting is not a published page, it creates or adopts a booking page and stores its ID in the settings.

rpress_reservation_settings_before_save( $new, $old )

Parameters

ParameterTypeDefaultDescription
$newmixedRequiredNew settings.
$oldmixedRequiredOld settings.

Returns mixed: The new settings, with reservation_page set when a page was created or found.

Internal. Defined in includes/features/reservations/pages.php, line 154.

rpress_reservation_flush_booking_page()#

Clears the cached booking page lookup when a page is saved, trashed or deleted.

Deletes the rpress_reservation_booking_page and rpress_customer_dashboard_page transients for pages.

rpress_reservation_flush_booking_page( $post_id )

Parameters

ParameterTypeDefaultDescription
$post_idintRequiredPost ID.

Internal. Defined in includes/features/reservations/pages.php, line 183.

rpress_reservation_page_setting()#

Adds the Reservation Page setting after Order History Page.

Filter callback on rpress_registered_settings. Inserts a page select into the General section that holds the other page settings.

rpress_reservation_page_setting( $settings )

Parameters

ParameterTypeDefaultDescription
$settingsarrayRequiredRegistered settings.

Returns array: The settings with the reservation_page field added.

Internal. Defined in includes/features/reservations/pages.php, line 200.

rpress_reservation_page_created_notice()#

Shows an admin notice after the booking page was created.

Shown once to users with the manage_shop_settings capability, with links to view and edit the page.

rpress_reservation_page_created_notice()

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reservations/pages.php, line 243.

rpress_register_reservation_post_type()#

Registers the rpress_reservation post type.

The type is non-public and uses the shop_payment capabilities, so anyone who manages orders manages reservations. Arguments are filterable with rpress_reservation_post_type_args. Hooked to init at priority 5.

rpress_register_reservation_post_type()

Internal. Defined in includes/features/reservations/post-type.php, line 23.

rpress_reservation_admin_menu()#

Adds Reservations as a RestroPress submenu with a pending count bubble.

Added as a plain submenu so it does not become the target of the main RestroPress menu link. The bubble shows the count from rpress_reservation_count_pending() for users who can edit reservations.

rpress_reservation_admin_menu()

Internal. Defined in includes/features/reservations/post-type.php, line 72.

rpress_reservation_settings_section()#

Adds the Reservations section to the General settings tab.

Filter callback on rpress_settings_sections_general.

rpress_reservation_settings_section( $sections )

Parameters

ParameterTypeDefaultDescription
$sectionsarrayRequiredGeneral sections.

Returns array: The sections with reservations added.

Internal. Defined in includes/features/reservations/settings.php, line 20.

rpress_reservation_email_settings_section()#

Adds the Reservation Notifications section to the Emails settings tab.

Filter callback on rpress_settings_sections_emails. Only adds the section when reservations are enabled.

rpress_reservation_email_settings_section( $sections )

Parameters

ParameterTypeDefaultDescription
$sectionsarrayRequiredEmail sections.

Returns array: The sections, with reservation_notifications added when enabled.

Internal. Defined in includes/features/reservations/settings.php, line 33.

rpress_reservation_register_settings()#

Registers the reservation settings fields.

Filter callback on rpress_registered_settings. While reservations are off only the enable switch is registered. When on, adds the General > Reservations fields and the Emails > Reservation Notifications fields, including a subject and message field for each email type. All fields pass through the rpress_reservation_registered_settings filter.

rpress_reservation_register_settings( $settings )

Parameters

ParameterTypeDefaultDescription
$settingsarrayRequiredRegistered settings.

Returns array: The settings with the reservation fields added.

Internal. Defined in includes/features/reservations/settings.php, line 49.

Was this page helpful?