Home Forums Event Espresso Premium Using wp_dropdown_pages for a custom booking form field.

Using wp_dropdown_pages for a custom booking form field.

Posted: March 8, 2018 at 8:48 am

March 8, 2018 at 8:48 am

Is it possible to add a custom dropdown field to a booking form, where the id’s and values in the dropdown are populated via the wp_dropdown_pages() method. In our case we use the WP_Query to return a list of Custom Post Types, the booking user will select one of these options.

function bhaa_emp_forms_output_field_input($html, $form, $field) {
		if($field['type']=='select' && $field['fieldid']==Runner::BHAA_RUNNER_COMPANY) {
			$sectorTeamQuery = new WP_Query(
					'post_type' => 'house',
					'order'		=> 'ASC',
					'post_status' => 'publish',
					'orderby' 	=> 'title',
					'nopaging' => true,
					'tax_query'	=> array(
							'taxonomy'  => 'teamtype',
							'field'     => 'slug',
							'terms'     => 'sector', // exclude house posts in the sectorteam custom teamtype taxonomy
							'operator'  => 'IN')
			$sectorTeamIds = implode(',',array_map(function($val){return $val->ID;},$sectorTeamQuery->posts) );
			$args = array (
				'id' => $field['fieldid'],
				'name' => $field['fieldid'],
				'echo' => 1,
				'post_type' => 'house',
				'exclude' => $sectorTeamIds);

			// an admin user is editing a runner page via the profile or edit-user pages.
			if (isset($_GET['user_id'])) {
				$runnerId = $_GET['user_id'];
				//error_log('user_id = '.$runnerId);
			} else {
				$runnerId = wp_get_current_user()->ID;
				//error_log('no <code>user_id</code> is defined, using wp_get_current_user() '.$runnerId);

			$selected = get_user_meta($runnerId,Runner::BHAA_RUNNER_COMPANY,true);
			// set the correct defaults for new or existing user
			if($selected==0||$selected=='') {
				$args = array_merge( $args, array( 'show_option_none' => 'Please select a company' ) );
				$args = array_merge( $args, array( 'option_none_value' => '1' ) );
			} else {
				$args = array_merge( $args, array( 'selected' => $selected ) );
			return $html;

I’m wondering what is the advise to achieve the same with the event expresso framework.


  • Support Staff

March 8, 2018 at 8:57 am

Hi Paul,

I don’t believe that particular example would be possible, but you can check with the dev team by opening an issue on Github:

There may be another way via using one of the hooks within Event Espresso.

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: publish

Updated by  Josh 2 weeks, 1 day ago ago

Topic Tags

Tagged: ,


This topic is: not resolved
Do NOT follow this link or you will be banned from the site!