Home Forums Add-ons Options Page Add custom message to option page


Add custom message to option page

    • roby94

    • March 19, 2017 at 12:47 am


    I need to add a custom message to the top of option page.
    I need to use some php code to display some values in the message box, there is any way to do it?

    Thank yuo

  • There isn’t anything built into ACF that will let you alter the options page to add a message to the top. A while back I posted an example of how this can be accomplished in my example acf filters and function repo on github

    • roby94

    • March 19, 2017 at 2:44 am

    Hi John!

    Thank you for your reply, it is exactly what i was looking for. I’ve got a small question. If i use it on top level page, it works perfectly, but i can’t make it works with sub option page.

    My code is:

    if( function_exists('acf_add_options_page') ) {
            'page_title' 	=> 'Impostazioni',
            'menu_title'	=> 'Impostazioni',
            'menu_slug' 	=> 'theme-trends-settings',
            'capability'	=> 'edit_posts',
            'redirect'	=> false
            'page_title' 	=> 'Forms',
            'menu_title'	=> 'Forms',
            'parent_slug'	=> 'theme-trends-settings',
            'page_title' 	=> 'Gestione livelli abbonamenti',
            'menu_title'	=> 'Gestione livelli abbonamenti',
            'parent_slug'	=> 'theme-trends-settings',
            'menu_slug'     => 'gestione-livelli-abbonamento'
    	add_action('theme-trends-settings_page_gestione-livelli-abbonamento', 'before_acf_options_page', 1);
    function before_acf_options_page() {}
    add_action('theme-trends-settings_page_gestione-livelli-abbonamento', 'after_acf_options_page', 20);
    function after_acf_options_page() {}

    What i’m doing wrong?
    Thank you

  • Some of this is guess work, but the hook should be what you have.


    If you want to do some testing, open the ACF file
    on line 459 you’ll find the function html

    function html() {
    		// add this line to test
    		echo '<br><br>',current_filter(),'<br><br>';

    if you temporarily add the above test code the hook that is being used to display the options page will be output at the top of your options page. I’d be curious to know what it is.

    • roby94

    • March 19, 2017 at 3:15 am

    Thank you John!!
    Using the current_filter() i’ve founded was i was doing wrong. The right one is:

    Basically it doesn’t use the “menu_slug” but use “menu_title”. (Maybe is my fault because i’ve used two different names).

    Anyway thank you very much!

  • That’s curious, when I test this it uses the menu slug every time.

  • So basically it’s a WordPress hook (not ACF hook), reference:

    Top level pages	admin.php?page={page_slug}	toplevel_page_{page_slug}
    Sub pages	admin.php?page={page_slug}	{parent_slug}_page_{page_slug}

    Thank you @hube2 for this ! πŸ™‚

    @roby94 reference says it is using slugs, and your final code does not corresponde with your initial code, so I just don’t believe it started using titles, that would be horrible approach.

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

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.