For developers, the Country and State Dropdown Add On offers two filter hooks. Use them to change the list of states for any country and to preselect a state for new members.
Filters
pmprosd_states
Filters the list of countries and their states, provinces, or regions. The list is keyed by two-letter country code, and each country holds an array of state codes and names. The state code is the value that’s saved.
How you set a country changes what members see:
- An array of states shows a State dropdown, and the field is required.
- An empty array hides the State field and makes it optional for that country.
- A country left out of the list gets a required State text field.
apply_filters( 'pmprosd_states', array $states );
Parameters
$states: array; Countries and their states as country code => array( state code => state name ). For example,'US' => array( 'AL' => 'Alabama', ... ).
Example: Add provinces for a country and remove options from the US list
function my_pmprosd_states( $states ) {
// Belgium is listed with no states. Give it a dropdown of provinces.
$states['BE'] = array(
'VAN' => 'Antwerp',
'WBR' => 'Walloon Brabant',
// Add the rest of the provinces here.
);
// Remove the Armed Forces options from the United States list.
unset( $states['US']['AA'], $states['US']['AE'], $states['US']['AP'] );
return $states;
}
add_filter( 'pmprosd_states', 'my_pmprosd_states' );
pmprosd_default_state
Filters the state to preselect for a country when the member hasn’t submitted or saved a state yet. It applies to the billing State field and to the Mailing Address Add On’s State field. Return a state code from the country’s list, or an empty string for no default.
The default only applies when the page loads, for the country selected at that point. If the member switches to another country and back, the State field starts empty. It isn’t used on the admin Edit Order screen, which always shows the state saved on the order.
apply_filters( 'pmprosd_default_state', string $state, string $country );
Parameters
$state: string; The default state code. Default empty string (no default).$country: string; The country code the state is for, such asUS.
Example: Preselect Pennsylvania for members in the United States
function my_pmprosd_default_state( $state, $country ) {
if ( 'US' === $country ) {
$state = 'PA';
}
return $state;
}
add_filter( 'pmprosd_default_state', 'my_pmprosd_default_state', 10, 2 );
Check the country before returning a state. The same filter runs for every country. For a country with a dropdown, a code that isn’t in its list is ignored, but for a country that shows a State text field, whatever you return is filled in as the default text.
Related Paid Memberships Pro Filters
The list of countries and the default country come from Paid Memberships Pro, not this Add On. Use the pmpro_countries filter to change the country list and the pmpro_default_country filter to change the default country. Our guide to customizing the country dropdown at checkout walks through both.
Get Support From Our Team of Experts
Have a question about how to use this feature? Our Support Page outlines three ways to get support.
Our Max plans include hands-on help customizing your membership site and implementing new features. Upgrade to PMPro Max now »
Last updated on November 19, 2026