# Put Your Main Countries First in Gravity Forms

> Moves the countries you sell to most to the top of Gravity Forms address and country drop-downs, so most visitors find theirs without scrolling.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: gravity-forms, address, countries
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/gf-countries-shortlist/

## Code

```php
$wpide_gf_top_countries = array( 'United States', 'Canada', 'United Kingdom' );
$wpide_gf_only_listed   = false; // True = offer only the countries above.

add_filter( 'gform_countries', function ( $countries ) use ( $wpide_gf_top_countries, $wpide_gf_only_listed ) {
    $countries = (array) $countries;
    $top       = array_values( array_intersect( $wpide_gf_top_countries, $countries ) );

    if ( $wpide_gf_only_listed ) {
        return $top;
    }

    return array_merge( $top, array_values( array_diff( $countries, $top ) ) );
} );
```

## Notes

Use the English country names exactly as Gravity Forms lists them; set $wpide_gf_only_listed to true to offer only those countries.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Put Your Main Countries First in Gravity Forms" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
