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.
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.