On this page
HowTo Create a 'country' profile field
Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites
This page describes how to create a 'country' field in your users' profiles, similar to the one on Drupal.org, that lets you easily find users in any country.
Note: Since Drupal 7.x, you will find user fields in Administration > Configuration > People > Account settings and then in Manage Fields tab.
- Create a new profile field.
- Go to the profile settings page (administer > settings > profiles ?q=admin/user/profile)
- Select the 'list selection' type of form field.
- Category (required): It can be a category you already have or a new one. (Suggested: Personal Information)
- Title (required): Anything is OK. (Suggested: Country)
- Form name (required): Anything is ok, as long as it is unique. (Suggested: profile_country)
- Explanation (optional): Usually, country is self explanatory, but you may want to write a note here to your users about this field.
- Selection options:
Defining a comprehensive list of sovereign states is a contentious diplomatic and political issue. Several lists exist on the Web:- The ISO International Standard list of country names and two-letter country codes (ISO standard 3166-1) is available in English and French in various formats. See http://www.iso.org/iso/country_codes.htm
- Wikipedia provides a list of sovereign states (http://en.wikipedia.org/wiki/List_of_sovereign_states), with links to the same list in languages other than English on the left.
- Weight: Select whatever you like (this is the weight in the category selected above).
- Visibility: Select one of the 'Public Field' options.
- Page title (required): You must put something here. (Suggested: People who live in)
- Check boxes: Check 'the user must enter a value' to make this field required. Check 'visible in user registration form' to make it part of user registration.
- Click on 'Save field.'
Due to the constantly changing nature of this data, it is often best to compose your own data from up-to-date information provided in the above links.
Country Codes API
There's a module (Country Codes API: http://drupal.org/project/countries_api ) that provides PHP API calls for translating country codes into official short names" by mechfish at http://drupal.org/node/402198#comment-1551426
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion