Customization

BA Event plugin is highly customizable!

You could use any custom post type as event from your theme or other plugins, turn on/off event page parts and change colors as described in Settings doc.

For next customization you will need some programming knowledge, but it will be easy to implement.

Change or re-order event page parts.

BA Event plugin adds next parts to event page: slideshow, features block, address with google map, testimonials block, faq block, booking calendar block.

These parts are integrated in event page via filters:

add_filter( 'ba_event_page_content', array( $this, 'event_page_slider'), 10, 1);
add_filter( 'ba_event_page_content', array( $this, 'event_page_features'), 20, 1);
add_filter( 'ba_event_page_content', array( $this, 'event_page_map'), 30, 1);
add_filter( 'ba_event_page_content', array( $this, 'event_page_faq'), 50, 1);
add_filter( 'ba_event_page_content', array( $this, 'event_page_testi'), 40, 1);
add_filter( 'ba_event_page_content', array( $this, 'event_page_avcal'), 60, 1);

All event post’s data are stored in post meta regarding WordPress codex, and we can get access to the main plugin’s class via global variable $BA_Event_var. So, for example, replacing a block slideshow will look like this code in your child theme:

///// remove slideshow filter
add_action( 'after_setup_theme', 'your_function_after_setup_theme' );
function your_function_after_setup_theme() {
    global $BA_Event_var;
    remove_filter( 'ba_event_page_content', array( $BA_Event_var, 'event_page_slider'), 10, 1);
}

//// place new slideshow after google map with priority 35
add_filter( 'ba_event_page_content', 'your_event_page_slider', 35, 1);
function your_event_page_slider(){
  global $post; //// this is our current event post
  $result = ''; //// we need return the result
  ///// get all post's meta from $post, do your stuff, do output to $result
  return $result;
}

Change All Events shortcode view.

All Events shortcode produces html output in WordPress WP_Query loop and you could change it as you need with the help of two filters in your child theme:

add_filter('ba_event_get_all_events_query', 'your_function_change_all_events_query_args');
function your_function_change_all_events_query_args($query_args){
    //// edit $query_args array as you need
    return $query_args;
}

add_filter('ba_event_get_all_events_item', 'your_function_change_all_events_item', 10, 2);
function your_function_change_all_events_item($event_item_html, (array)$event_data){
   //// event's data used in shortcode are stored in $event_data array
   //// get extra event data from $event_data['ID'] if needed
   //// create $new_event_item_html with your styles
   return $new_event_item_html;
}

Add custom fields to booking form

BA Event plugin uses the CMB2 code library for WordPress themes and plugins that makes it easy to add metaboxes, fields, and forms to WordPress (see more in CMB2 Wiki). With power of it will be easy to create new fields for booking form in next steps:

////// add custom text field on the front-end
add_filter ('ba_event_booking_form_fields', 'your_function_add_fields_to_booking_form');
function your_function_add_fields_to_booking_form($fields){
///// create new field with name _custom_field_1
$fields = '<div>
<label for="_custom_field_1">FIELD LABEL HERE</label><br>
///// if input field is required add to the input tag attribute required="required"
<input id="_custom_field_1" name="_custom_field_1" type="text" value="">
</div>';
return $fields;
}

///// save new field data with booking form
add_action('ba_event_create_booking', 'your_function_save_custom_fields');
function your_function_save_custom_fields($booking_id){
///// sanitize $_POST['_custom_field_1'] value
$new_field_value = sanitize_text_field($_POST['_custom_field_1']);
update_post_meta($booking_id, '_custom_field_1', $new_field_value);
}

///// add new field to the admin edit booking (reservation) screen with CMB2 library
add_action( 'ba_event_add_cmb2_booking_fields', 'your_function_new_cmb2_metabox' );
function your_function_new_cmb2_metabox($cmb){
$cmb->add_field( array(
'name' => 'FIELD LABEL HERE',
'id' => '_custom_field_1',
'type' => 'text',
) );
}

Comments are closed.