Support

Account

Home Forums Add-ons Options Page Customizing an Options Page

Solving

Customizing an Options Page

  • Is there a way to customize an options page? Specifically, I’m looking for a way to add a message under the page’s title? Like so:

    Options Page Title

    custom message to users here.

    [acf metaboxes ]

  • There isn’t any way to do this unless you edit ACF core files. You would need to edit /advanced-custom-fields-pro/pro/admin/views/options-page.php.

  • Yeah, I saw that. I dug deeper into the code and found the file. Was hoping there was an action hook in there!

  • I looked at everything all the way back to the WP function add_menu_page and() add_submenu_page()….

    When the pages are added the callback function for showing the page is acf_pro_options_page::html. There’s nothing that can be hooked once this function is called.

    There also does not seem to be a way to alter the callback function.

    You might possibly be able to do this by removing the hook that is added by WP and add your own hook for the options page to call a different callback function.

    For example, the hook for a top level options page looks something like this "toplevel_page_{$options_page_slug}", the hook for a sub page looks like this "{$parent_slug}_page_{$options_page_slug}" and an options page added to something like posts has a hook that looks like. "posts_page_{$options_page_slug}"

    But I’m not sure there is a way to remove ACF’s action so that you can add you own callback option. If you can figure out how to do this then you could write your own view page.

  • I think that this topic has come up in the past and the solution then was to use a message field at the top of the field group. You could try submitting a feature request through the ticket system to add some hooks to the options page view https://support.advancedcustomfields.com/new-ticket/

  • Thanks for all the research! One of the ways I tested was actually to build a child class that extends acf_pro_options_page Class and uses a custom html() method. This worked, but put the message under the fields, not at the top of the page like I expected. Maybe I’ll try the message field you mentioned.

    Thanks for all your help!

  • Well, I thought it was interesting so I looked into various ways to make changes to the options page. To be honest, I’m not comfortable hijacking the ACF callback function because that would mean that every time ACF updated the “View” for the options page that you’d need to rework anything that you do.

    I came up with this https://github.com/Hube2/acf-filters-and-functions/blob/master/customized-options-page.php. This method adds an action both before and after the ACF action so that you can capture the output from ACF and make changes to it after.

  • That’s definitely something I’ll look at! The most straight-forward way would be action hooks added directly on the options page. Maybe I’ll open a feature request.

  • The best way to add a feature request is to submit a new ticket https://support.advancedcustomfields.com/new-ticket/, it will get to the developer faster than posting it here on the forum. Like I said before, I’m pretty sure that this has been requested in the past.

  • Hi John and Darrin,

    any news about adding a hook in ACF Options page?

    I’d like to use ACF Options Page to manage all the settings, instead of adding other admin / options pages (e.g. to add a button to trigger a PHP function and do something with a file uploaded with ACF file field).

    I’ve opened a new ticket, as suggested by John, and I’ll update the thread as soon as I get an answer 😉

    Cheers,
    Davide

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

The topic ‘Customizing an Options Page’ is closed to new replies.