Home › Forums › Add-ons › Options Page › acf/save_post for specific options page › Reply To: acf/save_post for specific options page
I found a solution after reading this post: http://support.advancedcustomfields.com/forums/topic/when-using-save_post-action-how-do-you-identify-which-options-page/
While using WP get_current_screen()-function you can check if the ID in the output-array contains the slug of your specific option page.
http://codex.wordpress.org/Function_Reference/get_current_screen
For example you have an options page called “adverts” and want run the function mentioned above when you save this specific option page:
function clear_advert_main_transient() {
$screen = get_current_screen();
if (strpos($screen->id, "acf-options-adverts") == true) {
delete_transient('advert_main_transient1');
delete_transient('advert_main_transient2');
delete_transient('advert_main_transient3');
}
}
add_action('acf/save_post', 'clear_advert_main_transient', 20);
Now WP Transients make even more fun and will save you tons of queries if you have complex acf-fields and loops! 🙂
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.