Home Forums ACF PRO [CFT] Flexible Content values in update_value()


[CFT] Flexible Content values in update_value()

  • Hi there,

    I´ve create a custom field type and everything is working fine. Now I have to work with the value(s) of the field(s) when it gets saved/updated. My logic is working well for a single field, but not within a flexible content. I am using this function to receive the value of the field: function update_value( $value, $post_id, $field ).

    If I dump the data in context of FC, I only get the very first field and not the other ones. Dumping $_POST shows me that the values of all fields are in acf:{...}. Is there a native way to get a all values in both cases (single field / multiple fields), without creating my own logic if the field is in context of FC?

    I hope for a quick reply, thank you!

    Best regards


  • For my custom field type I needed to get all values at once and the function update_value( $value, $post_id, $field ) only handles each field seperate. Because the Amazon Product Advertising API only allows

    … an initial usage limit of 1 request per second*.

    I had to find another way.

    So after a while I realized, that the only way to get all fields at once on save, is to hook into acf/save_post before it gets modified.

    I have to place a seperate action hook into __constructor() / initialize():
    add_action('acf/save_post', array($this, 'on_save_values'), 1);
    and then iterate over all fields of acf:

    function on_save_values( $post_id ) {
                // bail early if no ACF data
    	        if( empty($_POST['acf']) ) {
    	        // array of field values
    	        $fields = $_POST['acf'];
                    foreach($fields as $layouts){

    Maybe this helps anyone facing similar problems.

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

The topic ‘[CFT] Flexible Content values in update_value()’ is closed to new replies.