Skip to content

Instantly share code, notes, and snippets.

@kbcarte
Created February 11, 2026 20:38
Show Gist options
  • Select an option

  • Save kbcarte/dfb7ff8c019604293b239cfa4cb22c5a to your computer and use it in GitHub Desktop.

Select an option

Save kbcarte/dfb7ff8c019604293b239cfa4cb22c5a to your computer and use it in GitHub Desktop.
Gravity Forms put USA at top of drop downs for countries, including drop down in Address field type
<?php
// Yoink: https://community.gravityforms.com/t/how-to-display-us-as-the-first-choice-but-leave-the-default-country-field-blank/17226/2
/**
* Set US to top of countries list in Gravity Forms.
*/
// Normal way
add_filter( 'gform_countries', 'modify_countries_list' );
function modify_countries_list( $countries ) {
$key = array_search( 'United States', $countries );
if ( $key !== false ) {
unset( $countries[ $key ] );
}
array_unshift( $countries, 'United States' );
return $countries;
}
// Roots Sage way
add_filter( 'gform_countries', function ( $countries ) {
$key = array_search( 'United States', $countries );
if ( $key !== false ) {
unset( $countries[ $key ] );
}
array_unshift( $countries, 'United States' );
return $countries;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment