Skip to content

Instantly share code, notes, and snippets.

@slaFFik
Created June 3, 2019 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slaFFik/fd3eae413f4d8036f1f6b06c2deb8f34 to your computer and use it in GitHub Desktop.
Save slaFFik/fd3eae413f4d8036f1f6b06c2deb8f34 to your computer and use it in GitHub Desktop.
WPForms: change the key of a country from country code to country name
<?php
add_filter( 'wpforms_countries', function ( $countries ) {
$key_from = 'CA';
if ( array_key_exists( $key_from, $countries ) ) {
$keys = array_keys( $countries );
$keys[ array_search( $key_from, $keys, true ) ] = 'Canada';
return array_combine( $keys, $countries );
}
return $countries;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment