Home › Forums › Bug Reports › Fields not saved if auto add pages to menu is checked › Reply To: Fields not saved if auto add pages to menu is checked
Hi guys
Thanks for the bug report!
This is a very facinating bug, and one which took quite some time to track down.
The good news is I have figured it out, and it can be fixed easily by making teh following change:
file: api/api-helpers.php
function: acf_verify_nonce
line: 683 (in v5.2.9)
function acf_verify_nonce( $value, $post_id = 0 ) {
// vars
$nonce = acf_maybe_get( $_POST, '_acfnonce' );
// bail early if no nonce or if nonce does not match (post|user|comment|term)
if( !$nonce || !wp_verify_nonce($nonce, $value) ) {
return false;
}
// if saving specific post
if( $post_id ) {
// vars
$form_post_id = (int) acf_maybe_get( $_POST, 'post_ID' );
$post_parent = wp_is_post_revision( $post_id );
// 1. no $_POST['post_id'] (shopp plugin)
if( !$form_post_id ) {
// do nothing (don't remove this if statement!)
// 2. direct match (this is the post we were editing)
} elseif( $post_id === $form_post_id ) {
// do nothing (don't remove this if statement!)
// 3. revision (this post is a revision of the post we were editing)
} elseif( $post_parent === $form_post_id ) {
// return true early and prevent $_POST['_acfnonce'] from being reset
// this will allow another save_post to save the real post
return true;
// 4. no match (this post is a custom created one during the save proccess via either WP or 3rd party)
} else {
// return false early and prevent $_POST['_acfnonce'] from being reset
// this will allow another save_post to save the real post
return false;
}
}
// reset nonce (only allow 1 save)
$_POST['_acfnonce'] = false;
// return
return true;
}
Please update to the latest 5.2.9, then make this change to the function!
Please let me know if it works for you
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.