Support

Account

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);
    }