Support

Account

Home Forums Backend Issues (wp-admin) acf/update_value – trying to understand

Unread

acf/update_value – trying to understand

  • I have a acf, secret, which often contains dollar signs (which they can’t), so I have to escape them before inserting into the db. So I found the function acf/update_value (and additional /key=secret), but I can’t seem to figure out how to implement the function.

    It takes three paramters, value, post-id and field. But I don’t understand how to implement the changes. This is my code

    /*
    @param $value The value that needs changing
    @param $post_id The post-id of the post
    @return $value The new value of the given field in the current post_type*/

    function pixl__fix_secret( $value, $post_id, $field ) {

    return str_replace(“$”, “\$”, $field[‘secret’] );

    }

    // acf/update_value – filter for every field
    add_filter(‘acf/update_value’, ‘pixl_fix_secret’, 20 , 3);

    Now, when I save, all my acf are blank.

Viewing 1 post (of 1 total)

The topic ‘acf/update_value – trying to understand’ is closed to new replies.