Event Organiser Pro 1.11.0 RC1

1.11.0 RC1 is now available upon request, with the intention of releasing 1.11.0 in the coming weeks. This release has been longer in the making than originally anticipated, but they are a lot of big improvements.

Please note that the minimum requirement for Pro has been raised from Event Organiser 2.0.0 to Event Organiser 2.1.0

Attendee questions

Details of this feature will be left for a dedicated post to follow. To summarise, this feature consists of two parts. Firstly tickets can now have meta data stored against them. Secondly, the form customiser API has been improved to allow you to add ‘attendee questions’.

‘Attendee questions’ are ordinary form fields which you can add using the form customiser API, and which are duplicated according to the number of tickets selected. The information collected from such fields are stored as ticket meta data for the appropriate ticket. So, for instance, you can collect individual ticket holder’s names, e-mail addresses, dietary requirements etc. This has been one of the most asked for features, so I’m pleased to be able to announce that this is now possible.

Price column hidden for free events

Another much requested feature was to hide the price column for free events. Clearly in such a context the column doesn’t serve much purpose, unless your site also sells priced tickets for some events and you want a consistent look (and perhaps also to emphasize the event is free).

While the ticket picker template could be edited to remove this column, it was decided that this was the more preferable default behaviour. If you wish to ‘undo’ this change and always display a price column you can do the following:

add_filter( 'eventorganiser_booking_element_classes', 'my_remove_free_event_html_class', 10, 2 );
function my_remove_free_event_html_class( $class, $element ) {
    if ( 'ticketpicker' == $element->type ) {
        $class = str_replace( 'eo-booking-free-event', '', $class );
    }
    return $class;  
}

(as with any snippet, this can go in a theme’s functions.php but it is recommended that you create your own site utility plug-in – see Where should I put code from the tutorials?).

Accessibility

This shall be recurring theme for future releases of Event Organiser and Pro. The aim is to achieve WCAG’s AA standard, and a lot of progress has been made with Event Organiser for 3.0.0 (due out later this year). That development runs parallel to improvements made to Event Organiser Pro. In both cases the focus shall initially be on admin pages as most front-facing parts of the plug-in can be over-ridden by themes. Nevertheless the intention is to ensure that front-facing content is also accessible by default.

In this release the focus has been on the booking form customiser, and in particular making it entirely keyboard accessible. On this page you can use the key “?” (shift + /) to display a modal detailing the keyboard shortcuts available.

If you do experience any accessibility issues, or anywhere improvements could be made, please raise this on the support forums or via this contact form.

Displaying ‘sold out’ rather than hiding sold out tickets

Until now, if a ticket type sold out it would be hidden from view. This can create a confusing user interface since it’s impossible to see if a ticket is simply not available (e.g. was never created, is not currently on sale) or if it has simply sold out. This behaviour has now changed to display the text ‘Sold out’.

If you wish to revert to the old behaviour you can do the following. Edit event-organiser-pro/templates/eo-ticket-picker.php, and remove the following line:

 <span class="eo-booking-ticket-sold-out"><?php esc_html_e( 'Sold out', 'eventorganiserp' );?></span>

It should be around line 79.

Please note that most language packs do not have “Sold out” translated, and so it will appear in English. To have that text translated please follow the instructions on this page, and get in touch when you do so. You shall be sent an updated language pack as soon as possible, and the translation shall be included in future updates.

Please note that if all tickets are sold out that then the tickets won’t appear, but instead a message saying the event has sold out will, as is the current behaviour.

Post-booking, pre-confirmation notification emails (for offline gateway)

Yet another much requested feature was to be able to send an e-mail to the bookee after they had made the booking, but before they had paid. This typically isn’t a problem for online payment gateways where the bookee will generally pay immediately. However, for bookings made with the offline payment gateway, there can be a period of time before the booking is confirmed and it would be desirable to inform the bookee that their booking had been received.

This had been achievable by following this tutorial but the plug-in now includes settings for a post-booking notification e-mail by default – no coding required.

Registering custom e-mail placeholders

Registering custom e-mail placeholders is now much simpler. They behave in a similar way to WordPress’ shortcodes: you can accept attributes.

To register an e-mail tag:

EO_Email_Template_Tag_Registry::register( 'mytag', 'mytag_callack' );
function mytag_callack( $tag, $atts, $context ){
    //$tag is 'mytag'
    //$atts is an array of attributes used with the tag
    //$context is an array indexed by 'booking_id', 'event_id', 'occurrence_id' etc. with
    //appropriate values for the context of the e-mail.

    return 'this replaces the placeholder';
}

Your callbacks must return a value, not print it

Then you’ll be able to use the tag %mytag% in your e-mail subject / content settings, and it will be replaced by the content returned by mytag_callack(). Attributes are supported, for example

%mytag foo=bar hello=world%

will pass

array(
    'foo'   => 'bar',
    'hello' => 'world',
)

as the second argument to the callback.

Please note that all placeholders are self-enclosing; you cannot enclose content within a placeholder

Registering custom views

There is now a ‘view’ factory. This factory class responsible for mapping element types ( input, select, textarea etc) to their view class. This can be used both for registering views for custom elements or replacing the views of default elements. A ‘view’ class is responsible for producing the HTML output of the element, and in most cases simply invokes a template. These templates can be found in event-organiser-pro/templates/booking-form and can be copied to the root of your theme and be edited if required. In this way you can also alter the mark-up of the booking form without replacing the existing view classes.

class My_Custom_Name_Field_View extends EO_Booking_Form_Element_View {

    function render() {
        //$this->element is the element class
        $html = ''; //generate desired html for this element
        return $html;
    }

}

//Register your view:
EO_Booking_Form_Element_View_Factory::register( 'name', 'My_Custom_Name_Field_View' ); //this replaces the default view for the name field with your custom one.

Adding & remove notices

There is now a filter to allow you to add, remove or change notices: eventorganiser_booking_form_form_display_notices.

This filters an array indexed by a notice ID, with the notice message as the value. The notice ID is simply a string to identify the message by. Default notice IDs include:

  • booking-complete, a notice which displays if the user is taken back to the form once they have completed their booking.
  • prior-booking – a notice which displays when a user has made a prior booking for this event
  • logged-in – the notice that appears when a user is logged in

The snippet below demonstrates how to change, remove and add notices:

add_filter( 'eventorganiser_booking_form_form_display_notices', 'my_booking_form_notices', 10, 2 );
function my_booking_form_notices( $notices, $booking_form_view ) {

    //Change the logged-in notice to use display name rather than e-mail
    if ( isset( $notices['logged-in'] ) ) {
        $current_user = wp_get_current_user();
        $notices['logged-in'] = sprintf(
            __( 'You are logged in as <strong>%s</strong>. <a href="%s">Not you?</a>', 'eventorganiserp' ),
            esc_attr( $current_user->display_name ),
            esc_url( wp_logout_url( get_permalink() ) )
        );
    }

    //Remove the prior booking notice:
    unset( $notices['prior-booking'] );

    //Add a custom notice
    $notices['my-custom-notice'] = 'This is a custom notice';

    return $notices;
}

Date Picker booking form element

For datepickers added to the booking form, the form customiser API allows you to configure most of the options listed here: http://api.jqueryui.com/datepicker/.

This is done by setting the data attribute of the field, using the data key: dp_<datepicker-option>.

<datepicker-options> here is not the setting as it appears on the jQuery UI page, but can derived using the following step:

  • Take the jQuery setting name (e.g. minDate) and precede each uppercase character with a hyphen (e.g. min-Date)
  • Lower case the string (e.g. min-date)

As demonstrated above, to set the jQuery minDate option, you would set the dp_min-date data attribute, as demonstrated below:

add_action( 'eventorganiser_get_event_booking_form', 'my_set_datepicker_settings', 10, 2 );
function my_set_datepicker_settings( $form, $event_id ) {

    //Get the datepicker to edit
    $datepicker = $form->get_element( 7 ); //change to ID of datepicker

    if ( ! $datepicker ) { 
         return;
    }

    //Get the data attribute (this will be an array)
    $data = $datepicker->get( 'data' );

    //Set the data attributes as required
    $data['dp_min-date'] = '+0d'; //Only allow dates after today
    $data['dp_max-date'] = '+20y'; //... and before 20 years time
    $data['dp_year-range'] = 'c-0:c+15'; //Restrict the year dropdown to +15 years
    $data['dp_append-text'] = '(dd-mm-yyyy)'; //Append text to the field
    $data['dp_show-week'] = true; //show week numbers

    //Update the datepicker with the new data attributes
    $datepicker->set( 'data', $data );

}

If you wanted to apply settings to all datepicker fields you could use the following to get an array of all datepicker fields in a form:

$all_elements = $form->flatten_elements();
$datepickers = wp_list_filter( $all_elements, array( 'type' => 'date' ) );
foreach ( $datepickers as $datepicker ) {
    ...
}     

Bugfixes

There are a few bugfixes included in this release too. Notably:

  • The issue with the admin calendar showing ‘out of date’ ticket sales has been fixed
  • Conflict with WordPress SEO has been fixed