Adding a new field for event submission form

Adding a country field for events

This tutorial shows how to edit fields based on the Editing Event Submission Form Fields doc and then output it on a single event listing.


Add the field to the frontend

Open up your theme functions.php field and create a function to append a new field to the events section. First hook it in:

add_filter( 'submit_event_form_fields', 'frontend_add_country_field' );

Then write the function:

function frontend_add_country_field( $fields ) {
  $fields['event']['event_country'] = array(
    'label'       => __( 'Country ($)', 'event_manager' ),
    'type'        => 'text',
    'required'    => true,
    'placeholder' => 'e.g. germmany'
  return $fields;

This adds a event text field at the bottom of the events form that has the label “Country”, is required, has no placeholder.

image missing

Fields added using the above code will be saved to the event listing automatically.

Add the field to admin

Again in theme functions.php, hook in your custom function:

add_filter( 'event_manager_event_listing_data_fields', 'admin_add_country_field' );

Then write your custom function:

function admin_add_country_field( $fields ) {
  $fields['_event_country'] = array(
    'label'       => __( 'Country ($)', 'event_manager' ),
    'type'        => 'text',
    'placeholder' => 'e.g. germmany',
    'description' => ''
  return $fields;

This add a text field to the admin meta box named “country”.

Image missing

Note, the field name is prepended with a ‘_’. This is because Event Manager makes your new fields hidden meta by prepending theme with an underscore. This is normal.