
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
AND
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?
Thanks
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:
array(
'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
E
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’
Thanks
E