Skip to content

Hooks and filters

24-Jan-11

EME provides a number of hooks and filters so you can customize a number of things to your liking. For a howto in general about hooks and filters, see here for actions and here for filters.
As an example, if you would want to hook into eme_insert_rsvp_action, you would add something like this to your theme’s functions.php:


add_action('eme_insert_rsvp_action','do_my_stuff');
function do_my_stuff($booking) {
 ....
}

The following hooks are available:

  • eme_insert_event_action (1 parameter: $event)
  • eme_update_event_action (1 parameter: $event)
  • eme_insert_recurrence_action (2 parameters: $event,$recurrence)
  • eme_update_recurrence_action (2 parameters: $event,$recurrence)
  • eme_insert_rsvp_action (1 parameter: $booking), executed after inserting rsvp info into the db
  • eme_update_rsvp_action (1 parameter: $booking), executed after updating booking info

The following filters are available:

  • eme_event_filter (1 parameter: $event array, return value should be modified array)
  • eme_event_list_filter (1 parameter: array of events, return value should be modified array)
  • eme_location_filter (1 parameter: $location array, return value should be modified array)
  • eme_location_list_filter (1 parameter: array of locations, return value should be modified array)
  • eme_directions_form_filter (1 parameter: generated html for the directions form, return value should be modified html)
  • eme_add_booking_form_filter and eme_delete_booking_form_filter (1parameter: generated html for the add or delete booking form, return value should be modified html)
  • eme_email_filter (1 parameter: email address or phone). If defined, the standard ascii obfuscating won’t take place and you can use your own filters, eg. from an obfuscating plugin, if you define it in functions.php:
    add_filter( ‘eme_email_filter’, ‘c2c_obfuscate_email’ );
    This filter is used to alter the obfuscation for email address and phone in mails sent.
  • eme_eval_booking_form_filter (2 parameters: $event, $booker). If defined, this function can do extra evaluations on the booking being done before it is recorded. You can use the $event, $booker and $_POST info for your evaluations. The return should be an array, with the first element of that array indicating that your evaluation is successful or not (1 or 0) and the second parameter a string indicating the reason if not successfull. Returning the array happens like this for success:
    array(0=>1,1=>”);
    or for failure:
    array(0=>0,1=>’The eval failed because of ….’);
  • eme_event_preinsert_filter (1 parameter: $event), taking place just before the event is inserted in the DB
  • eme_add_currencies (1 parameter: array of currencies), so you can add extra currencies to the list. Be aware that not all payment portals support all currencies.
    Example: to add Ghanaian Cedi (GHS) to the list of currencies, add the following to your theme’s functions.php:

    function my_eme_add_currencies($currencies){
    $currencies['GHS'] = ‘Ghanaian Cedi’;
    return $currencies;
    }
    add_filter(‘eme_add_currencies’,’my_eme_add_currencies’);

  • eme_categories_filter (1 parameter: array of categories) executed when searching for the categories (e.g. when creating an event). With this, you can e.g. limit the categories shown when creating an event or location or … .