Home › Forums › Backend Issues (wp-admin) › acf/save_post not working › Reply To: acf/save_post not working
Is this added to a file that is always loaded, like functions.php?
Is there anything for ACF to save? There are fields being submitted? If there are no ACF fields submitted the acf action will never fire.
function acf_save_post( $post_id = 0, $values = null ) {
// Override $_POST data with $values.
if( $values !== null ) {
$_POST['acf'] = $values;
}
// Bail early if no data to save.
if( empty($_POST['acf']) ) {
return false;
}
// Set form data (useful in various filters/actions).
acf_set_form_data( 'post_id', $post_id );
// Filter $_POST data for users without the 'unfiltered_html' capability.
if( !acf_allow_unfiltered_html() ) {
$_POST['acf'] = wp_kses_post_deep( $_POST['acf'] );
}
// Do generic action.
do_action( 'acf/save_post', $post_id );
// Return true.
return 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.