Created
March 7, 2023 02:24
-
-
Save DeveloperWil/03b58fb68684b2b2a283f3c0ea6afde2 to your computer and use it in GitHub Desktop.
Gravity Forms Australian Phone Number Formats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Provides specific formatting for Australian phone landlines and mobile numbers | |
* | |
* AU Mobile Format: XXXX XXX XXX | |
* Landline Mobile Format: XX XXXX XXXX | |
* | |
* @param $phone_formats | |
* @return mixed | |
*/ | |
function zpd_gf_phone_formats_au( $phone_formats ){ | |
$phone_formats['aulandline'] = array( | |
'label' => 'Australia Landline', | |
'mask' => '99 9999 9999', | |
'regex' => '/^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$/', | |
'instruction' => 'Australian landline phone numbers.', | |
); | |
$phone_formats['aumobile'] = array( | |
'label' => 'Australia Mobile', | |
'mask' => '9999 999 999', | |
'regex' => '/^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$/', | |
'instruction' => 'Australian mobile phone numbers.', | |
); | |
return $phone_formats; | |
} | |
add_filter( 'gform_phone_formats', 'zpd_gf_phone_formats_au' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment