Hey everyone,
Just wanted to share a snippet with the community for any UK based users.
By default, HivePress displays UK mobile numbers like +447543212345
But, with the following code snippet, this will transform into: 07543 212345
Add this via the Code Snippets plugin for easy maintenance:
add_filter('hivepress/v1/fields/phone/display_value', function($value, $field) {
if (strpos($value, '+44') === 0) {
$value = '0' . substr($value, 3);
} elseif (strpos($value, '+') === 0) {
$value = ltrim($value, '+');
}
if (strlen($value) === 11 && strpos($value, '07') === 0) {
$value = substr($value, 0, 5) . ' ' . substr($value, 5);
}
return $value;
}, 1000, 2);
Enjoy!
Cheers,
Chris