Home Forums Feedback Error in acf/pre_save_post documentation


Error in acf/pre_save_post documentation

  • In the code example on this page it says:

    if( $post_id != 'new' )

    When I believe it should be

    if( $post_id != 'new_post' )


  • Also worth noting that the priority would have to be 4 in order for new_post to still be available.

  • The value you would check for in your pre_save_post filter would be the same value you assign to “post_id” when setting up acf_form(). “new_post” is used as a default by ACF. If you use “new_post” in your acf_form() then ACF has a built in filter that runs on priority of 5 that will automatically create a new post of the post type “post”.

    If you are creating a new “post” then in most cases there isn’t any reason to have a pre_save_post filter of your own.

    What are you doing in your pre_save_post filter that requires special processing?

  • My comment is just about the documentation I don’t need assistance with my code. What is the purpose of the if( $post_id != 'new' ) part of the example in the docs?

  • I’ve read over it a few times and I think I’m starting to understand that it’s an old example of how to create a new post before the introduction of the new_post argument.

  • Yes, it is an old example from before that argument was added.

    The only reason for using this filter is that there is something custom you want to do that ACF does not do but in most cases you can replace a pre_save_post filter with an acf/save_post action.

    No, the documentation is not all 100% clear in this regard, but this is a user forum and the developers and maintainers of the documentation do not read these forums. If you think the documentation needs clarification then you need to contact the developers.

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

You must be logged in to reply to this topic.