Support

Account

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

  • 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']) ) {
    
    		        return;
    
    	        }
    	        // array of field values
    	        $fields = $_POST['acf'];
                    
                    foreach($fields as $layouts){
                        //...
            }

    Maybe this helps anyone facing similar problems.