The MU forums have moved to WordPress.org

How to hide admin menu items from users? (24 posts)

  1. deltakid
    Member
    Posted 15 years ago #

    I would like to hide the "Plugins" section from users. I already use the Plugin Manager and Plugin Commander and would like to be able to prevent users switchting plugins on and off.

    I guess the easiest method of doing this is just by hiding the menu point in the admin area (and maybe including a permissions check in the plugin.php file that only admins can access the page).

    Has anyone an idea how to do this?

  2. deltakid
    Member
    Posted 15 years ago #

    Ok.. ok I found a way to do this. Comment the lines 410 and 411 of your wp-admin/includes/mu.php out

    /* if( $menu_perms[ 'plugins' ] == 1 )
    $menu[35] = array(__('Plugins'), 'activate_plugins', 'plugins.php');*/

    Any other suggestions how to do this more elegant are appreciated.

  3. cafespain
    Member
    Posted 15 years ago #

    Or go to the Site admin menu, click on Options.
    Scroll down to the bottom and uncheck the Enabled box next to the Plugins option.

  4. Ovidiu
    Member
    Posted 15 years ago #

    but I thought with plugin commander yo ucoudl auto activate a plugin, and do not give user control over it, combined with disabling the "normal" plugins menu that is the solution?

  5. deltakid
    Member
    Posted 15 years ago #

    No cafespain if I do this I can't use plugins or enable them individually for single blogs.

  6. boonika
    Member
    Posted 15 years ago #

    @Ovidiu

    That's right. That's how I do it.

  7. cafespain
    Member
    Posted 15 years ago #

    @deltakid: Yes you can. You switch on the plugins menu - activate the plugin for the users blog and switch off the plugins menu. Takes less than 30 seconds. But then I only have a few sites so it isn't much hassle for me.

  8. dsader
    Member
    Posted 15 years ago #

    deltakid,

    I use an mu-plugin to reshape the menu for all blogs/users.

    http://mu.wordpress.org/forums/topic.php?id=8482

  9. deltakid
    Member
    Posted 15 years ago #

    yes cafespain that works as well. that was how i did it initially. but now i get emails when a user has filled out a certain form and just click a link to activate the appropriate plugin for his blog. that's easier for me.

    and thanks dsader that's perfect! works great and a very elegant solution much appreciated!

  10. boonika
    Member
    Posted 15 years ago #

  11. boonika
    Member
    Posted 15 years ago #

    @dsader

    Your solution works excellent. Thanks a lot. But what about hiding Advanced Options (Excerpt, Trackbacks,...)?

  12. dsader
    Member
    Posted 15 years ago #

    Boonika, look closely at the edit-form-advanced.php for the divs with id, and add style to the header to hide the div. Add something like this to an mu-plugin:

    <?php function ds_hide_post_form () {
    ?>
    <style>
    #postcustom	{
    	display: none;
    }
    #pagepostcustom	{
    	display: none;
    }
    #postexcerpt	{
    	display: none;
    }
    #trackbacksdiv {
    	display: none;
    }
    </style>
    <?php }
    add_action( 'admin_head', 'ds_hide_post_form' );
    ?>
  13. boonika
    Member
    Posted 15 years ago #

    That's what I did. Searched inside edit-form-advanced.php and found those lines of code but didn't know how to write a plugin to disable those functions. Thanks a lot for this simple solution.

  14. boonika
    Member
    Posted 15 years ago #

    @dsader

    Now this is strange. I swear that your 'redirect' plugin yesterday worked just fine. Now, when I enter direct URL, for example; http://blog1.example.com/wp-admin/post-new.php redirect doesn't work which means that I'm able to visit actual URL.

    Also, the solution you provided in your last post works GRAET but only for Write/Post and not for Write/Page Advanced Options. They are still displayed.

    I forgot to say something that might be important. I'm using those plugins as Plugins, not MU-Plugins. I've added header so I can activate them inside the administration.

    Anyway, once again, thanks for your help.

  15. boonika
    Member
    Posted 15 years ago #

    @dsader - 'redirect' problem solved

    Sorry, looks like it was my lack of knowledge. I just pasted your code which has only themes.php included. That's why redirect didn't work for other pages.

  16. boonika
    Member
    Posted 15 years ago #

    @dsader - 'hide Wrie/Page options' problem solved

    Thanks

  17. dsader
    Member
    Posted 15 years ago #

    Boonika,
    Look at the edit-page-form.php to modify display of the page editor.

    The divs ids change names depending on the version.

  18. boonika
    Member
    Posted 15 years ago #

    @dsader

    Yes that's what I already did. Right now I'm struggling with hiding Dashboard. Actually, I'm trying to apply above mentioned 'redirect' function. All other menus (ones that I don't need) are hidden and when user enters hidden menu URL he gets redirected to page-new.php.

  19. boonika
    Member
    Posted 15 years ago #

    Maybe this will do the 'hide Dashboard' trick:
    http://www.deepwave.net/articles/hide_dashboard/

  20. dsader
    Member
    Posted 15 years ago #

    add to a mu-plugin

    function ds_hide_dash() {
    wp_redirect('post-new.php');
    		exit();
    	}
    add_action( 'wp_dashboard_setup','ds_hide_dash' );
  21. boonika
    Member
    Posted 15 years ago #

    Thanks dsader. You've helped me a lot. I think that you should collect all those codes and create a plugin called 'Dsader Admin Options' or something like that... just a thought. Thanks.

  22. dsader
    Member
    Posted 15 years ago #

  23. boonika
    Member
    Posted 15 years ago #

    When I think about it now, I couldn't agree with you more. More people should KISS:)

  24. musnake
    Member
    Posted 15 years ago #

    Yes, a _dilute_koolaid.php is in order, with a bit of this for the crafty...

About this Topic

  • Started 15 years ago by deltakid
  • Latest reply from musnake