Home / Admin / Create Additional Schemes for the Address Field
Duplicate Snippet

Embed Snippet on Your Site

Create Additional Schemes for the Address Field

This snippet will show you how to create your own Scheme for the Address field. This example creates a Canadian-specific address scheme.

<10
Code Preview
php
<?php
/**
 * WPForms Add new address field scheme (Canada)
 *
 * @link   https://wpforms.com/developers/create-additional-schemes-for-the-address-field/
 * 
 * For support, please visit: https://www.facebook.com/groups/wpformsvip
 */
 
function wpf_dev_new_address_scheme( $schemes ) {
 
    $schemes[ 'canada' ] = array(
        'label' => 'Canada',
        'address1_label' => 'Address Line 1',
        'address2_label' => 'Address Line 2',
        'city_label' => 'City',
        'postal_label' => 'Code Postal',
        'state_label' => 'Province',
        'states' => array(
            'BC' => 'British Columbia',
            'ON' => 'Ontario',
            'QC' => 'Quebec',
            'AB' => 'Alberta',
            'MB' => 'Manitoba',
            'NB' => 'New Brunswick',
            'NL' => 'Newfoundland and Labrador',
            'NT' => 'Northwest Territories',
            'NS' => 'Nova Scotia',
            'NU' => 'Nunavut',
            'PE' => 'Prince Edward Island',
            'SK' => 'Saskatchewan',
            'YT' => 'Yukon',
            ),
    );
 
    return $schemes;
 
}
 
add_filter( 'wpforms_address_schemes', 'wpf_dev_new_address_scheme', 10, 1);

Comments

Add a Comment