I’m trying to hide a help page from editors, added by the gravity forms plugin. I believe I’ve run into the same issue before with other plugins, so I’d like to know the correct way to do it for 3rd party plugins. This is what I have so far which does not work. It does of course work for other WP menus so I’m wondering if the function is only limited to WP menus?
function remove_menu_links() {
if( !current_user_can('manage_options') ) {
remove_menu_page('admin.php?page=gf_help'); // this is the pages url
}
}
add_action( 'admin_menu', 'remove_menu_links');
Ok, Eugene’s Answer works in the case of a plugin that doesn’t deals with custom capabilities.
So, if his code works without checking for the capability, we have to look how GravityForms executes his
add_submenu_page
action.And for that, we drop the whole plugin folder inside a good code editor (NotePad++, TextMate, etc) and do a global search and find our stuff.
And a few lines before we see:
Now we go ahead with Members plugin, which btw GF recognizes, and we have the following in its config screen for the Editor role.
BUT NOTING THAT
gform_full_access
doesn’t appears in this list. It has to be manually added through the plugin interface…After that and marking the full access capability, the
remove_submenu_page
works as expected to the Editor role.Reference code for all submenus (remembering the first one is the very top menu).
Plugin of interest
Adminimize does this hiding magic in the blink of an eye and is completely PRO.
You need to add your hook at the end of the queue and then remove menu by slug:
If you want to remove submenu you need to use following snippet:
The GravityForms plugin renames the top level menu item to match the first of the sub-menu.
For example; if you’ve added just the gravityforms_view_entries capability to the Editor role, then the first sub-menu item will be “Entries”, so the parent menu will be “gf_entries” not “gf_edit_forms”. So, the following code will remove the “Help” item from the sub-menu for Editors with just that capability:
Hope this helps.
This was driving me insane. The answers provided here got me most of the way, but that particular darned Gravity Forms menu item is a little weird.
I managed to get to the root of it by analysing the $submenu global variable which contains all the menu data. The following snippet should kill the update submenu item for you, when hooked into admin_menu() as listed above 🙂
Nothing above worked for me, but at least I can hide it with CSS.
#toplevel_page_gf_help{display:none;}
you can hide it with css only if you want,
search for a plugin to add css on admin panel :