Home Forums Event Espresso Premium Default country with default states

Default country with default states

Posted: February 14, 2021 at 8:45 pm


February 14, 2021 at 8:45 pm

I added the following code found here to the functions.php file to show the US as default country on oure reg form. But I also need the states list to default to the US states as well. Or, even better, to only show states that are applicable to the chosen country. Right now, it’s endless scrolling on the states list to get to the US to choose a state. Can you provide something to help us with this?
Thank you.

function my_change_default_ee_country_option(){
$custom_js = ‘jQuery(document).ready(function($){‘;
$custom_js .= ‘$(“.ee-reg-qstn-country”).val(“US”);’;
$custom_js .= ‘});’;
wp_add_inline_script(‘ee_form_section_validation’, $custom_js);


  • Support Staff

February 16, 2021 at 6:18 am

Hi there,

That’s actually exactly what happens if you manually select a Country, the other ‘states’ are filtered out of the state options.

However, with the above code setting the value using .val() doesn’t trigger the change event EE uses to do this, so that needs to be called manually.


$custom_js .= '$(".ee-reg-qstn-country").val("US");';

To this:

$custom_js .= '$(".ee-reg-qstn-country").val("US").trigger("change");';

Does it work then?


February 16, 2021 at 9:17 am

That took care of it – thank you so much!


  • Support Staff

February 16, 2021 at 9:18 am

You’re most welcome.

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  Tony 2 weeks, 1 day ago ago

Topic Tags


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