Field Render

Display a Phone Number field which use the Intl Tel Input library.

Field Group

Field Settings

Setting nameDescription
Allow CountriesFilter which countries can be chosen
Preferred CountriesDefine the countries to appear at the top of the list
Default CountrySet the initial country selection
GeolocationLookup the user’s country based on their IP address
Native NamesShow native country names
National ModeAllow users to enter national numbers
Allow DropdownWhether or not to allow the dropdown
Separate Dial CodeDisplay the country dial code next to the selected flag
Default ValueMust be international number with prefix. ie: +1201-555-0123
PlaceholderYou may use {placeholder} to print the country phone number placeholder
Return ValueReturn the phone number array or the phone number

Field Value

Return Format: Phone Number

$phone_number = get_field('phone_number');

// +12015550123

Return Format: Phone Array

$phone_number = get_field('phone_number');

/**
 * array(
 *     'number'        => '+12015550123',
 *     'country'       => 'us',
 *     'national'      => '+12015550123',
 *     'international' => '+12015550123',
 * )
 */

Return Format: Phone Array (with addon)

$phone_number = get_field('phone_number');

/**
 * array(
 *     'number'        => '+12015550123',
 *     'country'       => 'us',
 *     'national'      => '(201) 555-0123',
 *     'international' => '+1 201-555-0123',
 * )
 */

Return Format: National Number (with addon)

$phone_number = get_field('phone_number');

// (201) 555-0123

Return Format: International Number (with addon)

$phone_number = get_field('phone_number');

// +1 201-555-0123

Unformatted Value

$phone_number = get_field('phone_number', false, false);

// +12015550123

Phone Number Addon

By default the field is bundled with a Javascript validation method which use the builtin libphonenumber library included in Intl Tel Input.

While this method work in 95% of the case, some users may bypass that validation by disabling their browser Javascript. In order to validate the field from the server, and make sure the phone is always validated, we recommend to include the libphonenumber for PHP library.

We decided to not include that library by default, as it weighs more than 10MB and we want to keep ACF Extended as much lightweight as possible. You can easily include that library using the ACF Extended libphonenumber for PHP addon. Once activated, the field will automatically use the server validation from the library.