fbpx
Did you miss our exclusive webinar on Attendee information? Click here to view the recorded session.
How can we help?

Adding a country field for events

In this guide, you will learn about how you can add a country field to your event submission form based on the Event Submission Form Fields doc and showcase it on a single event listing.

Adding a field to the frontend

In order to add fields on the front end Event Submission Form, you need to make changes in the PHP file.

  1. Open your theme functions.php field.
  2. 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' );
  3. Add the code :
    
    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 an event text field at the bottom of the events form that has the label “Country”, is required, and has no placeholder.

This adds an event text field at the bottom of the events form. This text field contains the label Country and it has no placeholder.

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

Add the field to admin Meta box

In order to add a field to the Admin meta box, follow the steps:

  1. Open your theme functions.php field.
  2. Hook in your custom function in theme functions.php,
    add_filter( 'event_manager_event_listing_data_fields', 'admin_add_country_field' );

Next add 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 adds a text field to the admin meta box named “country”.

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

Adding A Country Field For Events
Ashok Dudhat

Our team constantly explores ways that technology can help us reinvent industries. We want to change the world by creating great products that transform industries. We Dream It, We Make It.

Quick Links
Close
Close