PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

remove "forms" menu item from admin

  1. In my functions file i have some code to remove various WP Menu items.

    function remove_menu_items() {
      global $menu;
      $restricted = array(__('Links'), __('Comments'), __('Media'),
      __('Plugins'), __('Tools'), __('Users'), __('Pages'), __('Posts'), __('Dashboard'), __('Forms'), __('Appearance'), __('Settings'));
      end ($menu);
      while (prev($menu)){
        $value = explode(' ',$menu[key($menu)][0]);
        if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){
          unset($menu[key($menu)]);}
        }
      }
    
    add_action('admin_menu', 'remove_menu_items');
    ?>

    Everything works as expected except for the "forms" menu item".

    What am i missing?

    Thanks

    Posted 12 years ago on Thursday July 7, 2011 | Permalink
  2. Any Ideas

    Posted 12 years ago on Thursday July 7, 2011 | Permalink
  3. There were a couple of things that needed to be changed in your code.
    Try the following

    function remove_menu_items() {
      global $menu;
      $restricted = array(__('Links'), __('Comments'), __('Media'),
      __('Plugins'), __('Tools'), __('Users'), __('Pages'), __('Posts'), __('Dashboard'), __('Forms'), __('Appearance'), __('Settings'));
      end ($menu);
      do
      {
        $value = explode(' ',$menu[key($menu)][0]);
        if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){
          unset($menu[key($menu)]);}
        }
        while (prev($menu));
      }
    add_action('admin_menu', 'remove_menu_items', 11);
    Posted 12 years ago on Thursday July 7, 2011 | Permalink