Home › Forums › General Issues › Calculation… › Reply To: Calculation…
Saving field values into an array in the options table, actually, this is the easy bit.
add_action('acf/save_post', 'my_save_statistics');
function my_save_statistics($post_id) {
// array holding list of fields to save to options array
fields = array(
'list',
'of',
'field',
'names',
'to',
'save'
);
$all_stats = get_options('all_stats', array());
$post_stats = array();
foreach ($fields as $field) {
$post_stats[$field] = get_field($field, $post_id);
}
$all_stats[$post_id] = $post_stats;
update_options('all_stats', $all_stats, true);
}
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.