WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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');
share|improve this question
up vote 3 down vote accepted

Ok, Eugene's Answer works in the case of a plugin that doesn't deals with custom capabilities.

The WordPress Plugin API allows Roles and Capabilities to be added, removed and changed. Since Plugins might change Roles and Capabilities, just the default ones are addressed in this article.

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.

// wp-content/plugins/gravityforms/gravityforms.php
// all parameters removed from the original code, except $page_title and $capability
    __("Help", "gravityforms"),
    $has_full_access ? "gform_full_access" : $min_cap, 

And a few lines before we see:

$has_full_access = current_user_can("gform_full_access");
$min_cap = GFCommon::current_user_can_which(GFCommon::all_caps());
    $min_cap = "gform_full_access";

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...

enter image description here

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).

function remove_menu_links() {
    if( !current_user_can( 'manage_options' ) ) {
        // remove_submenu_page( 'gf_edit_forms', 'gf_edit_forms' ); 
        // remove_submenu_page( 'gf_edit_forms', 'gf_new_form' ); 
        // remove_submenu_page( 'gf_edit_forms', 'gf_new_formf_help' ); 
        // remove_submenu_page( 'gf_edit_forms', 'gf_entries' ); 
        // remove_submenu_page( 'gf_edit_forms', 'gf_settings' ); 
        // remove_submenu_page( 'gf_edit_forms', 'gf_export' ); 
        // remove_submenu_page( 'gf_edit_forms', 'gf_update' ); 
        // remove_submenu_page( 'gf_edit_forms', 'gf_addons' ); 
        remove_submenu_page( 'gf_edit_forms', 'gf_help' ); 
add_action( 'admin_menu', 'remove_menu_links', 9999 );

Plugin of interest

Adminimize does this hiding magic in the blink of an eye and is completely PRO.

share|improve this answer
thank you for your comprehensive answer and for looking into the source of GF. I've now added the gform_full_access capability and the help has gone as expected. It does open up another can of worms in that all the other menu links are now accessible but I've hidden them all with the function :) I've had this problem in the past with disabling 3rd party menu links but I think I'm a lot more comfortable with it now. – Andrew Jul 18 '12 at 3:04
@Andrew : I missed a couple of issues and updated my answer. Looks like the help page is considered pretty harmless and available to all caps current_user_can_which(GFCommon::all_caps()).. .. .. If you really want to block the access and not only hide the menu, probably some admin_head or admin_init coupled with current_user_can, $pagenow and wp_die could do the job. – brasofilo Jul 18 '12 at 3:13

You need to add your hook at the end of the queue and then remove menu by slug:

function remove_menu_links() {
    if( !current_user_can( 'manage_options' ) ) {
        remove_menu_page( 'gf_edit_forms' ); // this is the pages url
add_action( 'admin_menu', 'remove_menu_links', 9999 );

If you want to remove submenu you need to use following snippet:

function remove_menu_links() {
    if( !current_user_can( 'manage_options' ) ) {
        remove_submenu_page( 'gf_edit_forms', 'gf_help' ); 
add_action( 'admin_menu', 'remove_menu_links', 9999 );
share|improve this answer
Thanks, didn't seem to work though. Any other ideas? – Andrew Apr 7 '12 at 7:47
Probably you want to remove submenu item. I have updated my answer and added snippet to remove submenu item. – Eugene Manuilov Apr 7 '12 at 7:54
I was unsuccessful with that also. The problem seems to be that it doesn't have a top menu slug. The full url when I hover over the link is website.com/wp-admin/admin.php?page=gf_help – Andrew Apr 7 '12 at 8:01
@Andrew : Just edited the code and the remove_* works ok. The question is: do editors have GravityForms capability? . . . 'Cause that doesn't seem to be true. – brasofilo Jul 16 '12 at 12:30
@brasofilo point taken ... i didn't mean anything negative by my comment. I've paid for a developers licence for Gravity Forms and always found that they've got back to me in < 24 hours. i think there is a page on GF dedicated to the hooks and roles & permissions. – Damien Jul 18 '12 at 8:02

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 :)

remove_submenu_page( 'gf_edit_forms', 'gf_update' ); 
share|improve this answer

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:

function remove_menu_links() {
    remove_submenu_page( 'gf_entries', 'gf_help' );
add_action( 'admin_menu', 'remove_menu_links', 9999 )

Hope this helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.