ACF – Options page Hook (WordPress)

I am really making a huge use of ACF’s options pages and repeater fields.
In order to reduce the amount of queries (from about 500 to 80) I’m caching some field outputs with the help of WordPress Transient API.

I know the hook for ACF options pages is:

Read More
add_action( 'acf/save_post', 'reference_function') ); 

But the problem for me is, that I have multiple options pages. And I don’t want all my functions to run when any options page is saved…

These are my current options pages

add_filter('acf/options_page/settings', 'my_acf_options_page_settings');
if(function_exists("register_options_page")) {
        acf_add_options_page();
        register_options_page('Spielübersicht');
        register_options_page('Mannschaft');
        register_options_page('SCHWALBE arena TV');
        register_options_page('Sponsoren');
        register_options_page('Werbung');
        register_options_page('Einstellung');
        register_options_page('Fanclubs');
        register_options_page('Sidebar');
    }

Is there a way to filter the action so that my transients are only created when the related options page is saved?

Related posts

Leave a Reply

1 comment

  1. Luckily I was able to solve my problem!
    Have a look at my code in the plugins’ support forum:
    http://support.advancedcustomfields.com/forums/topic/acfsave_post-for-specific-options-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);