Support

Account

Home Forums Bug Reports Fields not saved if auto add pages to menu is checked

Solved

Fields not saved if auto add pages to menu is checked

  • This bug show up only the first time you try to save a static page.

    If the option “Automatically add new top-level pages to this menu” is flagged (this option is located in Appereance->Menus) and you click “New Page”, insert the title, fill the acf fields and save, acf fields will not saved. After first saving fields will be saved.

    If that menu option is not flagged, everything works fine and every acf field will be saved first time you attempt to save a new page.

    I’m using ACF 5.1.5.

  • I’m also having this issue.

  • I’m still having this issue, on the latest version (5.2.3 on WPv4.2). Is there any update on this?

    Seems to be quite a major issue given that many sites will have this turned on by default.

    Thanks.

  • I am having the same Problem. With Version 5.2.9 it’s still not solved. Tested it with the first Version 5 and there it is also not working.
    When I used the old PlugIn (not Pro) it is working (but I’m not downgrading for sure 😉 ) So I hope there will be a solution soon. Thank you

  • Yes, this does appear to be a bug. I will see what I can to about getting the developers attention.

  • 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

  • Fantastic. What a fast reply :).
    Yes it’s working now for me.
    Thank you!!

  • To tell the true not so fast, I open this ticket in february.
    Anyway we all knows how hard is follow everything in a big project. 🙂
    Hope to see new replies even in others feature requests (that I opened).
    Thanks for the resolution!!

  • Hi @virgodesign

    Thanks mate. Yes, I have missed many bug reports of late, and do apologies about that.

    With @hube2 helping on the forum, we are finding and fixing everything!

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘Fields not saved if auto add pages to menu is checked’ is closed to new replies.