Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BHWD/ed7d8b0d5a1490007ad3f2362c9c02d3 to your computer and use it in GitHub Desktop.
Save BHWD/ed7d8b0d5a1490007ad3f2362c9c02d3 to your computer and use it in GitHub Desktop.
Change Caldera Forms phone field default country. See: https://calderaforms.com/doc/caldera_forms_phone_js_options/
<?php
/**
* Set preffered countries for Caldera Forms phone fields
*/
add_filter( 'caldera_forms_phone_js_options', function( $options){
//Use ISO_3166-1_alpha-2 formatted country code
$options[ 'preferredCountries' ] = array( 'MX' );
return $options;
});
<?php
/**
* Set intiial country for Caldera Forms phone fields
*/
add_filter( 'caldera_forms_phone_js_options', function( $options){
//Use ISO_3166-1_alpha-2 formatted country code
$options[ 'initialCountry' ] = 'CH';
return $options;
});
<?php
/**
* Show only specific countries' flag in Caldera Forms phone fields
*/
add_filter( 'caldera_forms_phone_js_options', function($options ){
$options[ 'onlyCountries' ] = array( 'cn', 'tw' );
return $options;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment