acf_save_post

Overview

This action works on version 3.5.8.2 and below. If using version 4, please use acf/save_post

Description

This action is called when a page / post / options page / taxonomy / user / attachment is saved.

ACF uses this hook to save the $_POST[‘fields’] data. (acf.php line 1705) with a priority of 10.

Usage

This action contains one parameter: $post_id

You can use this action to save / modify the $_POST data of the fields. eg:

<?php

function my_acf_save_post( $post_id )
{
	// vars
	$fields = false;

	// load from post
	if( isset($_POST['fields']) )
	{
		$fields = $_POST['fields'];
	}

	// ...
}

// run before ACF saves the $_POST['fields'] data
add_action('acf_save_post', 'my_acf_save_post', 1);

// run after ACF saves the $_POST['fields'] data
add_action('acf_save_post', 'my_acf_save_post', 20);

?>