Home › Forums › Backend Issues (wp-admin) › Detecting what has just been saved when using save_post action › Reply To: Detecting what has just been saved when using save_post action
There isn’t any way to know what options page is being saved, normally. ACF passes the post ID to your filter for acf/save_post. For options pages this values is always ‘option’ or maybe it’s ‘options’, don’t remember exactly right now. The best you can hope for under this condition is running your function for every options page.
When setting up an options page, acf has an option to use a specific post ID. This post ID can belong to any valid post. If you use the post ID option for the options page then you can tell when the specific options are being saved.
I have a plugin that actually creates options pages. This plugin creates a custom post type to store information about the settings of each options page. There is also a setting that lets you save the values of fields on the options page to the post ID of the options page CPT. I have also used hidden post_mata names (they all begin with _) so that none of the settings that you enter will interfere with functions like get_fields(), or get_field_objects(). https://github.com/Hube2/acf-options-page-adder, even if you don’t use it you might get some ideas from looking at it.
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.