Hey TStone,
We’ve had a number of requests to change this and will add a setting in a future update.
Are you comfortable with PHP? In the mean time, you could change the code that handles the phone number format.
Open up the “helper-functions.php” file in the “inc” folder for the plugin’s files. Find line 145 and change the ‘($1) $2-$3’ to your preferred format:
return preg_replace( '/([0-9]{3})([0-9]{3})([0-9]{4})/', '($1) $2-$3', $raw_number );
You might also want to change the numbers in brackets {3},{3},{4}, to however phone numbers are broken up. For example, this will change the phone number format to something like “23-4545-3434”:
return preg_replace( '/([0-9]{2})([0-9]{4})([0-9]{4})/', '$1-$2-$3', $raw_number );
Hopefully that helps! Otherwise look for an update in February that addresses this.
– Craig
Thread Starter
TStone
(@tstone)
Thank you!
Yes, I’m somewhat comfortable with PHP (though regex makes me shudder).
I’m fine with waiting to the next update though. It isn’t a bug, it just…looks really weird. 🙂
Do you use your own functions to validate and format? If so, maybe a peek at Googles libphonenumber might be useful, unless it is a complete overkill.
https://github.com/giggsey/libphonenumber-for-php
https://github.com/brick/phonenumber
I would agree that it’s an annoying detail though. Internationalizing the plugin is a recent focus so you’ll continue to see improvements as updates come out.
Thanks for the suggestions here! I love to have users offer ideas and improvements that they come across. Currently it’s just a simple bit of code to format phone numbers. The code in the repository you suggested might be a bit overkill to include in the plugin but I’ll definitely take a look to see how I can use it as a reference. I’m leaning towards a simple setting that can be used to customize number formats in the backend and for CSV exports. We will see once I start testing out some ideas though.
– Craig
Hello again,
Version 2.1 includes some options for formatting 10 digit phone numbers as well as a hook for endless customization. I’m hoping this helps! I’m also looking to collect additional formats that our users need.
I figured this would be better than including a large library. I do appreciate you finding those repos for me though!
Here is a link to how you can create your own custom formats:
https://roundupwp.com/faq/format-phone-numbers/
– Craig