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.
- 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.
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