WPForms State Dropdown

Add a dropdown field to your form, and under “Advanced Options” add “state” as a CSS class.  Then add the following code to your theme’s functions.php file or core functionality plugin.

* State Dropdown
* @author Bill Erickson
* @see http://www.billerickson.net/code/wpforms-state-dropdown/
* @param array $field
* @param array $field_atts
* @param array $form_data
* @return array $field
function ea_state_dropdown( $field, $field_atts, $form_data ) {
if( ! in_array( 'state', $field_atts['field_class'] ) )
return $field;
$field['choices'] = array();
$states = wpforms_us_states();
foreach( $states as $value => $label )
$field['choices'][] = array( 'label' => $label, 'value' => $value );
return $field;
add_filter( 'wpforms_select_field_display', 'ea_state_dropdown', 10, 3 );
view raw functions.php hosted with ❤ by GitHub


Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk