HostelPRO Developers API

From version 1.7 the WordPress plugin HostelPRO supports basic API to help deveopers extend its functionality. The API currently provides mostly hooks fired when some data in the system is added or changed – i.e. booking is made, room is added, field is deleted etc.

If you need a specific hook or filter to be added please contact  us at hi@wp-hostel.com and it may be added to the next version.

Available API Hooks in Models:

These hooks are do_action calls fired when item is added, modified or deleted. They should be caught by add_action calls.

Main plugin file:

do_action(‘hostelpro_admin_menu’);   – called after all menu links. Lets you plug your custom menu links under the HostelPRO menu.

do_action(‘hostelpro_init’); – called when the plugin initialization is completed.

Rooms:

do_action(‘hostelpro_room_added’, $id); – when room is added. Passes the room ID.

do_action(‘hostelpro_room_edited’, $id, $vars); – when room is edited. Passes the room ID and the full array of new data (typically coming from $_POST).

do_action(‘hostelpro_room_deleted’, $id); – when room is deleted. Passes the field ID.

Bookings:

do_action(‘hostelpro_booking_paid’, $id); – when booking is paid (either from admin or verified Paypal / Stripe payment)

do_action(‘hostelpro_booking_added’, $id); – when booking is added. Passes the booking ID.

do_action(‘hostelpro_booking_edited’, $id, $vars); – when field is edited. Passes the booking ID and the full array of new data (typically coming from $_POST).

do_action(‘hostelpro_booking_deleted’, $id); – when bookin g is deleted. Passes the booking ID.

do_action(‘hostelpro_booking_cancelled’, $id); – when booking is cancelled.

do_action(‘hostelpro_booking_data_saved’, $id, $vars);– when the custom data about booking is saved (the data from the custom fields).

Addon Services:

do_action(‘hostelpro_addon_added’, $id); – when addon service is added. Passes the addon ID.

do_action(‘hostelpro_addon_edited’, $id, $vars); – when addon service is edited. Passes the addon ID and the full array of new data (typically coming from $_POST).

Discounts / Surcharges:

do_action(‘hostelpro_discount_added’, $id); – when discount / surcharge is added. Passes the discount / surcharge ID.

do_action(‘hostelpro_discount_edited’, $id, $vars); – when discount / surcharge is edited. Passes the discount / surcharge ID and the full array of new data (typically coming from $_POST).

do_action(‘hostelpro_discount_deleted’, $id); – when discount / surcharge is deleted. Passes the discount / surcharge ID.

Booking Form Fields:

do_action(‘hostelpro_field_added’, $id); – when field is added. Passes the field ID.

do_action(‘hostelpro_field_edited’, $id, $vars); – when field is edited. Passes the field ID and the full array of new data (typically coming from $_POST).

do_action(‘hostelpro_field_deleted’, $id); – when field is deleted. Passes the field ID.

Available API Hooks in the Views

In addition  to the above actions each of the admin pages for editing an item also let you add your own form elements on it so you can process custom data with the form:

do_action (‘hostelpro_booking_form’, @$booking) is on the Add / Edit Booking form. Passes the $booking object in case of editing.

do_action (‘hostelpro_room _form’, @$room) is on the Add / Edit Room  form. Passes the $room object in case of editing.

do_action (‘hostelpro_field_form’, @$field) is on the Add / Edit Field form. Passes the $field object in case of editing.

do_action (‘hostelpro_discount_form’, @$discount) is on the Add / Edit Discount / Surcharge form. Passes the $discount object in case of editing.

do_action (‘hostelpro_addon_form’, @$addon) is on the Add / Edit Addon  form. Passes the $addon object in case of editing.