Home Forums General Issues acf/format_value for specific field


acf/format_value for specific field

  • Is there a way to apply the acf/format_value filter to a specific field (not a specific type) only.

    I tried:

    function my_acf_format_value( $value, $post_id, $field ) {
    if ($field == 'my_field_key') {
    	// return
    	return $value.' - test';
    else {
    return $value;
    add_filter('acf/format_value', 'my_acf_format_value', 10, 3);

    But didn’t work.

  • Got it – Need to check $field['name'] value.

    • amos

    • August 14, 2019 at 1:23 am

    hi ben,
    I’m trying to add text before a user-filled field. For example: Add TEL: Before a phone number entered by the user, how do I do this? Similar to what you did?

    They didn’t let me post a comment in Hebrew;)

  • Why don’t use the prefix option?

    • amos

    • August 14, 2019 at 7:58 pm

    Because I’m a noob…
    I saw it here on the forum

    $phone = get_field('phone-number');
    <a href="tel:<?php echo $phone; ?>"><?php echo $phone; ?></a>

    But I have no idea where to put it ..

  • What i mean is using the simple “prefix” option in the field options, without using code at all.

    What are you trying to do?

    • amos

    • August 14, 2019 at 8:13 pm

    I have hundreds of posts with this phone number, it’s a user-editable business card and I don’t want him to be able to delete the TEL:

  • Does he have access to the ACF Admin? (and if he does, can’t you just block it? Very good plugin here btw)

    • amos

    • August 14, 2019 at 8:20 pm

    the user has access only to the front and ..
    And I do want him to have the access to edit his phone number – the process of creating a business card – is also almost completely automatic

    • amos

    • August 14, 2019 at 8:23 pm

    Today, at the time of the card creation, a line of telephone already have the TEL: but it is erasable – and ugly

  • So ill ask again πŸ™‚

    Why don’t use the prefix option?

    It will apply to every phone out there and he won’t be bale to change it.

    • amos

    • August 14, 2019 at 8:29 pm

    I probably don’t know how to do it .. I understand it’s a simple thing, but how to do it?
    If it’s too much already, I’ll try to dig some more online πŸ™‚

  • Don’t dig too deep πŸ™‚

    It’s Append.

  • Sorry, “Prepend” in your case.

    • amos

    • August 14, 2019 at 10:45 pm

    I tried, the problem is:
    I associate the value entered with a dynamic field in elementor.
    The dynamic field is a URL field
    The output I get is this which is not good for me – so looking for more options .. πŸ™‚

  • What is the output you need?

    • amos

    • August 14, 2019 at 10:52 pm

    and few more – i just need to figure out the first and that’s it πŸ™‚

  • I can try to help, but i need some details about how you setup everything, you write very short and vaguely…

    • amos

    • August 14, 2019 at 11:24 pm

    First of all thank you!
    I prefer to speak in our native language, how can we communicate except here? Facebook? whatsapp? Mile?
    tizckeh le mitzvot!

  • This reply has been marked as private.
    • amos

    • August 14, 2019 at 11:39 pm

    Can’t see …
    here Try this πŸ™‚

Viewing 21 posts - 1 through 21 (of 21 total)

You must be logged in to reply to this topic.

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.