Home Forums Backend Issues (wp-admin) Hiding Options Page from a role


Hiding Options Page from a role

  • Hi

    I have the Options Page addon and have it set up correctly.

    However I would like to hide/disable the Options Page in the main menu for anyone who is NOT an administrator.

    So far I have this…

    Show this field group if

    Options Page IS EQUAL to General Settings
    Logged in User Type IS EQUAL to Administrator

    I also added this to my functions file…

    add_action( 'admin_menu', 'remove_links_menu_contributors' );
    function remove_links_menu_contributors() {
    	if(!current_user_can('create_users')) {
    	remove_menu_page('index.php'); // Remove Dashboard
    	remove_menu_page('admin.php?page=acf-options-general'); // Remove ACF Options

    Plus, I have this in my functions.php file…

    	// options pages
    	function my_acf_options_page_settings( $settings )
    		$settings['title'] = 'General Settings';
    		$settings['pages'] = array('General', 'Extras');
    		return $settings;
    	add_filter('acf/options_page/settings', 'my_acf_options_page_settings');

    However this doesnt work, and the Option is still showing on the main menu on the left hand side of wp-admin.

    Any advice please?


  • Hi @codynew

    The options page settings filter allows more customization than what is in the documentation. If you print out the $settings array, you will see something like this:

    			'title' 		=> __('Options','acf'),
    			'menu'			=> __('Options','acf'),
    			'slug' 			=> 'acf-options',
    			'capability'	=> 'edit_posts',
    			'pages' 		=> array(),

    Here you can see that an arg of capability will allow you to customize the role to see this menu item.


  • Thanks Elliot

    Where should I add that code you’ve noted please?

  • Hi @codynew

    The above array is the default $settings for the filter add_filter('acf/options_page/settings', 'my_acf_options_page_settings');

    You can use the filter code which you already have, and just edit the ‘capability’ in a similar way to how you have edited the ‘title’


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

The topic ‘Hiding Options Page from a role’ is closed to new replies.