Adding a country field for events

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:
  1. add_filter( 'submit_event_form_fields', 'frontend_add_country_field' );
  1. Add the code :
  1. function frontend_add_country_field( $fields ) {
  2.   $fields['event']['event_country'] = array(
  3.     'label'       => __( 'Country ($)', 'event_manager' ),
  4.     'type'        => 'text',
  5.     'required'    => true,
  6.     'placeholder' => 'e.g. germmany'
  7.   );
  8.   return $fields;
  9. }

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,
  1. add_filter( 'event_manager_event_listing_data_fields', 'admin_add_country_field' );
  1. Next add your custom function:
  1. function admin_add_country_field( $fields ) {
  2.   $fields['_event_country'] = array(
  3.     'label'       => __( 'Country ($)', 'event_manager' ),
  4.     'type'        => 'text',
  5.     'placeholder' => 'e.g. germmany',
  6.     'description' => ''
  7.   );
  8.   return $fields;
  9. }

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.

    • Related Articles

    • Event Listings Page Settings

      Under the Event Manager tab, you can see the Settings section that helps you manage your event listings and the way it appears on your website. 1.Listings Per Page How to change the total number of listings showing per page? (Event Listings Page ...
    • Event Submission Page Settings

      To access the event submission settings page, follow the below mentioned steps. Go to Event Manager >> Settings >> Event Submission tab. Account Required: This account refers to the account that a user needs to create to post an event listing. ...
    • Other Settings

      The Pages tab under the settings option contains the settings that help you make changes to the destination pages. These destination pages have the shortcodes to create WP Event Manager Plugin pages like Event forms page, the event dashboards page, ...
    • General Settings

      The settings submenu for the WP Event Manager plugin is placed in the sidebar of the WP admin. To go to the General Settings, follow the below mentioned steps: WP Admin >> Event Manager >> Settings >> General Settings on the left sidebar of the ...
    • Default Content Settings

      The Default Content option in the WP Event Manager settings section allows users to save time by selecting organizer, venue and address of events in advance as default so that they dont have to add the organizer, venue and address to each event that ...