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


Hiding Options Page from a role

    • codynew

    • January 20, 2014 at 6:33 pm


    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?


    • Elliot

    • January 21, 2014 at 5:37 pm

    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.


    • codynew

    • January 22, 2014 at 8:41 am

    Thanks Elliot

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

    • Elliot

    • January 23, 2014 at 11:48 am

    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)

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.