Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active June 1, 2023 19:59
Show Gist options
  • Save joshfeck/fc06d0485b2afd367fb5ef1bba96890f to your computer and use it in GitHub Desktop.
Save joshfeck/fc06d0485b2afd367fb5ef1bba96890f to your computer and use it in GitHub Desktop.
Make the Country field default to US and State field default to North Carolina. Event Espresso 4 Registration form step.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action(
'wp_enqueue_scripts',
'my_change_default_ee_country_option',
20
);
function my_change_default_ee_country_option(){
$custom_js = 'jQuery(document).ready(function($){';
$custom_js .= '$(".ee-reg-qstn-country").val("US");'; // United States
$custom_js .= '$(".ee-reg-qstn-state").val(38);'; // North Carolina
$custom_js .= '});';
wp_add_inline_script('ee_form_section_validation', $custom_js);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment