Skip to content
PHP

How to Modify Gravity Forms Country by Hook

A
Author
Apr 17, 2023 · 1 min read
How to Modify Gravity Forms Country by Hook

This example demonstrates how to limit the country drop down to only a few select countries.

add_filter( 'gform_countries', 'remove_country' );
function remove_country( $countries ){
    return array('Brazil', 'United States', 'Netherlands', 'United Kingdom' );
}

This example demonstrates how to add new countries to the list.

add_filter( 'gform_countries', function ( $countries ) {
    $countries[] = 'Country 1';
    $countries[] = 'Country 2';
 
    sort( $countries );
 
    return $countries;
} );
A
Author

Author at The Creative Coders.

The monthly build log

One email a month. New posts, lessons, and the occasional strong opinion. No spam.