Does your membership site primarily serve one region or country of members?
This recipe demonstrates how to set the default country (United States — US) for your PMPro-powered membership site. This is useful for sites that collect a Billing Address and want to speed up the checkout process, eliminating the need for members to find their country before proceeding.
This code recipe uses the pmpro_default_country
filter to pre-set the dropdown at checkout to your country of choice. If your country isn’t in the list, you can also add it using the pmpro_countries filter.
The Code Recipe
Adding the Recipe to Your Website
You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.
Change the country code on line of the code recipe below to match your own. The code recipe above is currently set to GB
“United Kingdom”. For a list of supported country codes see includes/countries.php. If the country you would like to use is not in this list, you can add it using the pmpro_countries
filter hook.
Check out these related articles:
- Restrict Membership Signup by Country
- Allow members to select Country and State via dropdown at Membership Checkout
- How to adjust your membership site’s default currency format
Free Course: Membership Site Development—The Basics
Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.