I am trying to figure out how to confine contact form submissions to just one Canadian province. This is for a service business that only works in one area, but we continue to get submissions from other provinces. How can I have the province field be a default to just one province and not have a dropdown that offers any other selections?
Hi Andrea. I think I replied to you on Facebook. Thanks for opening a community topic.
Can you share a link to the page on your site where we can see the form? And I assume this is a default address field, which offers multiple provinces, and you want to only show one province available?
Hi Andrea. You can override the list of Canadian Provinces using the gform_address_types filter, like this:
add_filter( 'gform_address_types', 'limited_provinces', 10, 2 );
function limited_provinces( $address_types, $form_id ) {
$address_types['canadian']['states'] = array ( 'British Columbia ');
return $address_types;
}
That is PHP code which can be added to your theme functions.php file, or you can use a plugin such as this one to keep the code separate from the theme: Code Snippets – WordPress plugin | WordPress.org
If you need anything else, please let us know.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.