You can accomplish this via the save_post
action:
add_action( 'save_post', 'wpa78558_save_average_meta', 100 );
function wpa78558_save_average_meta( $post_id ) {
if ( !wp_is_post_revision( $post_id ) ) {
$graphics = get_field('graphics', $post_id);
$gameplay = get_field('game-play', $post_id);
$life = get_field('life', $post_id);
$sound = get_field('sound', $post_id);
$overall = $graphics + $gameplay + $life + $sound;
$overall = $overall / 4;
if (is_float($overall)) { $overall = number_format($overall,1); }
update_post_meta($post_id, 'overall', $overall);
}
}
You can add additional checks in here for a specific post type (see example on save_post
codex page), or verify that your field values exist before saving the meta data.
The average will be saved under the meta key overall
and can be output in the template or referenced in a query.