Home Forums Feature Requests Options page: allow me to hide the Publish meta box


Options page: allow me to hide the Publish meta box

  • When using options pages, I would like the ability to hide the Publish meta box and the Update button inside it.

    My options page is used only for a bunch of custom buttons that fire off AJAX calls to do certain tasks like sync data with 3rd party services or to manually run cron jobs, etc.

    In my case, the “Update” button, when clicked, will make ACF remember the state of all of the checkboxes on the page. This is kind of annoying because I want those check boxes to always be checked by default (they’re just settings for what to sync).

    I’m already registering these fields programmatically, so being able to do something like this would be ideal I think:

    acf_add_local_field_group( ['hide_on_screen' => 'publish'] )

    In the mean time I’m using JS to block the submit of the form and to hide the Publish meta box. It works but this would be better.

    Mucho thanks

    PS. I know I could make a native WP admin page, but being able to call acf_add_options_sub_page() then acf_add_local_field_group() is soooo much better than returning piles HTML in PHP function returns…

  • G’day Mate,

    the submit area is just a regular wp meta box. If it’s regular wp metabox, then it can be removed.

    with a quick deep following the breadcrumb, these are the general process for an option page:

    1) /pro/admin/admin-options-page.php line 29, which added the all acf options pages via the “admin_menu” hook

    2) inside the “admin_menu” hook’s function, it then add the admin_load function via the “load-{$slug}” actions. (where $slug is the acf option page slug)

    3) in that admin_load function, it then add add the admin_head function via the “acf/input/admin_head” action.

    4) in that admin_head function, that’s where the meta box is being added with “add_meta_box”. (line 200)

    which mean, we could just call ‘remove_meta_box’ after the “load-{$slug}” action to remove the metabox.

    But now you may ask, how in the heck can you get that $slug? well, if you look at the menu page function in the codex, (line 1190)

    the $slug is get_plugin_page_hookname($menu_slug, $parent_slug), which the $menu_slug in acf is $page[‘menu_slug’] and $parent_slug is $page[‘parent_slug’].

    So, for example, if you have an option page that’s added with,

    acf_add_options_sub_page('Theme Tasks');,

    then, $page[‘parent_slug’] is “acf-options” and
    $page[‘menu_slug’] is 'acf-options-' . sanitize_title( $page['menu_title'] );,
    aka, ‘acf-options-theme-tasks’.

    Therefore, to retrieve the $slug, you can call get_plugin_page_hookname('acf-options-theme-tasks', 'acf-options')

    ======= with all info from above, we can then come up with =======

    acf_add_options_sub_page('Theme Tasks');
    add_action('admin_menu', 'maybe_find_and_remove_that_meta_box', 100, 0);
    function maybe_find_and_remove_that_meta_box() {
        $option_page_slug = get_plugin_page_hookname('acf-options-theme-tasks', 'acf-options');
        add_action("load-{$option_page_slug}", 'add_that_remove_meta_box_action', 11);
    function add_that_remove_meta_box_action() {
        add_action('acf/input/admin_head', 'remove_that_damn_meta_box', 11);
        // also change it to 1 column, so you don't have empty sidebar 
        add_screen_option('layout_columns', array('max' => 1, 'default' => 1));
    function remove_that_damn_meta_box() {
        remove_meta_box('submitdiv', 'acf_options_page', 'side');

    I know this might be a lot to take in. Have fun 🙂


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

The topic ‘Options page: allow me to hide the Publish meta box’ is closed to new replies.