Home › Forums › Backend Issues (wp-admin) › Phone field with href="tel:" link › Reply To: Phone field with href="tel:" link
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).
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.