I am trying to accomplish the same thing and this works for me:
add_filter(‘acf/format_value/name=phone_provider’, ‘convert_phone_to_link’, 20, 3);
function convert_phone_to_link ($value, $post_id, $field) {
if (!$value) {
// no value
return $value;
}
$tel_link= ‘+1’.preg_replace(‘/[^0-9]/’, ”, $value);
$value = ‘tel:’.$tel_link;
return $value;
}
However, this causes the other button on the page, with a “mailto:” link to also show the phone popup. So clicking only on the phone button it works. However if you click on the button with the mailto: link which is supposed to only open your email program, it also shows the phone popup. Any idea why that would conflict?
(Note: I am using elementor. I also tried the javascript adding the class name to my button, but that did nothing at all).