Option to disable menu for site owner (uid = 1)

smoothify - March 24, 2009 - 19:00
Project:SimpleMenu
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

I would like the ability to disable simplemenu for the site owner user account.

Since the user with uid of 1 inherits all user_access permissions its not possible to hide it for this user.

I'd like for the site editors to use simple menu, but the site admin to use admin_menu.

Thanks

Ben

#1

Keyz - April 10, 2009 - 11:02

Also interested in this. I love admin menu for "admin" stuff... but SimpleMenu is well, much "simpler" for regular users :D
Having SimpleMenu enabled for regular users means the admin (who's may prefer using admin menu) gets a stack of two menus.

I'm sure it would be done differently to expose the option in SimpleMenu's UI, though here's a tweak to simplemenu.module to give the desired result for the time being:

  // do a simple access check here, since theme isn't available to check yet
  global $user;
  if (user_access('view simplemenu') && $user->uid != '1') {

$global user; was added so that we get access to the user object and see who the current user is... then an extra condition && $user->uid != '1' is added so that it says "if the user has permission to view simplemenu AND if the user is not uid 1, then proceed".

Then to get it to not load SimpleMenu's footer code/javascript in this case:

function simplemenu_footer() {
  global $user;
  if(simplemenu_enabled() && $user->uid != '1') {

Note that I'm not an expert coder and though I think it's fine and my testing showed no negative side effects, use at your own risk.
Hope this helps, and +1 on the feature request :)

#2

superstar - June 8, 2009 - 00:27

This feature would be better maintained if it was able to be switched on and off via the administration page for simple menu.

I will look at rolling a patch for this.

#3

psynaptic - June 11, 2009 - 13:05
Status:active» needs review

Just did this..

  • Adds a function _simplemenu_superuser_active() which tests if $user->uid == 1 and if variable_get('simplemenu_uid1', 1) == 0.
  • Adds a checkbox form item to the bottom of the advanced settings to control simplemenu_uid1 variable.
  • Adds extra simplemenu_enabled() check to simplemenu_init() to avoid loading JS and CSS files when not enabled.

Quite a simple patch really. I was going to add in role visibility too but then I realised that can be controlled via the permissions system.

AttachmentSize
simplemenu-superuser_active.patch 2.06 KB

#4

Jolidog - August 3, 2009 - 00:01
Status:needs review» reviewed & tested by the community

Works great!

Thank you very much.

#5

psynaptic - August 3, 2009 - 19:56

No problem.

I'm with Keyz, I agree that simplemenu is better for certain, shall we say, "less technical" users. ;)

I used to use simplemenu exclusively but have come to like admin_menu so I can now finally say:

simplemenu++
admin_menu++

#6

cimo - August 23, 2009 - 08:11

AWESOME !

#7

psynaptic - September 9, 2009 - 07:49

I think this still needs to be committed, is that correct?

#8

Jolidog - September 12, 2009 - 22:50

yes, please! :)

 
 

Drupal is a registered trademark of Dries Buytaert.