EllisLab text mark
Advanced Search
     
Hiding certain menu items
Posted: 01 August 2012 02:30 PM   [ Ignore ]
Joined: 2012-07-30
13 posts

Hi! 

What would be the best way to hide certain menu items for certain member groups? For example, on the myaccount.php page I’d like to only leave ‘edit profile’... And also remove the access to the other pages to that member group.

My idea now is to modify _account_menu.php so that some menu items are not shown, depending on the group_id of the user. In this case, I would have some kind of ‘if’ variable, and hide for example this line:

<li><a href="<?=BASE.AMP.'C=myaccount'.AMP.'M=edit_signature'.AMP.'id='.$id?>"><?=lang('edit_signature')?></a></li

Is there a better way?

Thanks!

 
Posted: 01 August 2012 07:35 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-24
1161 posts

My recommendation would be to write an Extension using the cp_menu_array hook and create your own custom logic around the url query string (for the page(s) being viewed) and the member’s group.

If you aren’t comfortable writing an extension you should check out the Zoo Flexible Admin add-on.

 Signature 

@ErikReagan
GitHub Repos
Focus Lab, LLC
EE Pro Network

 
Posted: 02 August 2012 01:21 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-07-30
13 posts

Thanks!

I started creating the extension already, and was able to add/remove some of the menu items on the main bar.

I have a couple of questions regarding this though.

1) Is there a list somewhere of all the possible menu items? For example I was trying to remove the help menu but wasn’t able to (I tried

unset($menu['help']
)... I can’t find anywhere the reference to it. Doing
print_r($menu

did not show it.

2) Does this allow to access the inner pages? It looks to me that is is only for the menu at the top, so if I’m in the ‘my account’ page this has nothing to do with options like ‘Edit Avatar’, ‘Email Settings’, etc? Or am I wrong?

3) What about this plug in? -> http://devot-ee.com/add-ons/zoo-flexible-admin

Thanks!

 
Posted: 02 August 2012 01:30 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-24
1161 posts
_fyi - 02 August 2012 01:21 PM

1) Is there a list somewhere of all the possible menu items? For example I was trying to remove the help menu but wasn’t able to (I tried

unset($menu['help']
)... I can’t find anywhere the reference to it.

No list. It changes from page to page actually. The bad news about the “Help” item is that it’s added after the hook is executed. You can’t remove that one with the extension.

_fyi - 02 August 2012 01:21 PM

2) Does this allow to access the inner pages? It looks to me that is is only for the menu at the top, so if I’m in the ‘my account’ page this has nothing to do with options like ‘Edit Avatar’, ‘Email Settings’, etc? Or am I wrong?

Yes, it’s only the menu at the top. No more.

_fyi - 02 August 2012 01:21 PM

3) What about this plug in? -> http://devot-ee.com/add-ons/zoo-flexible-admin

That’s the same one I linked above. I haven’t tried it personally but I’ve heard great things about it.

 Signature 

@ErikReagan
GitHub Repos
Focus Lab, LLC
EE Pro Network

 
Posted: 02 August 2012 02:23 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2012-07-30
13 posts
Erik Reagan - 02 August 2012 01:30 PM
_fyi - 02 August 2012 01:21 PM

1) Is there a list somewhere of all the possible menu items? For example I was trying to remove the help menu but wasn’t able to (I tried

unset($menu['help']
)... I can’t find anywhere the reference to it.

No list. It changes from page to page actually. The bad news about the “Help” item is that it’s added after the hook is executed. You can’t remove that one with the extension.

_fyi - 02 August 2012 01:21 PM

2) Does this allow to access the inner pages? It looks to me that is is only for the menu at the top, so if I’m in the ‘my account’ page this has nothing to do with options like ‘Edit Avatar’, ‘Email Settings’, etc? Or am I wrong?

Yes, it’s only the menu at the top. No more.

_fyi - 02 August 2012 01:21 PM

3) What about this plug in? -> http://devot-ee.com/add-ons/zoo-flexible-admin

That’s the same one I linked above. I haven’t tried it personally but I’ve heard great things about it.

Thanks for your answers! And oops sorry, forgot about your link smile

So, back to my original question… What I’m willing to achieve is to customize the ‘Edit Signature’, ‘Edit Avatar’, etc… Those will not be needed on my application… I want to remove those according to the user group. What can I do? Just modify the _account_menu.php file? It feels a bit hacky to have to do this. Any other options?

Thanks again!

 
Posted: 02 August 2012 03:43 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-24
1161 posts
_fyi - 02 August 2012 02:23 PM

What I’m willing to achieve is to customize the ‘Edit Signature’, ‘Edit Avatar’, etc… Those will not be needed on my application… I want to remove those according to the user group. What can I do? Just modify the _account_menu.php file? It feels a bit hacky to have to do this. Any other options?

You’re probably best of manually editing that file as you’ve determined. It means you have to maintain the change/hack as you upgrade EE in the future though.

The only other alternative I can think of is to use javascript to manipulate the DOM, but that’s a bit hacky as well smile

 Signature 

@ErikReagan
GitHub Repos
Focus Lab, LLC
EE Pro Network

 
Posted: 02 August 2012 03:47 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2012-07-30
13 posts
Erik Reagan - 02 August 2012 03:43 PM
_fyi - 02 August 2012 02:23 PM

What I’m willing to achieve is to customize the ‘Edit Signature’, ‘Edit Avatar’, etc… Those will not be needed on my application… I want to remove those according to the user group. What can I do? Just modify the _account_menu.php file? It feels a bit hacky to have to do this. Any other options?

You’re probably best of manually editing that file as you’ve determined. It means you have to maintain the change/hack as you upgrade EE in the future though.

The only other alternative I can think of is to use javascript to manipulate the DOM, but that’s a bit hacky as well smile

Yeah… I’m currently experimenting with the config, to keep ‘hackyness’ at a minimum…. But still I guess I’ll need to modify some of the views anyways…

Thank you very much again for your help and hope to see you soon around!

 
Posted: 02 August 2012 03:52 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2009-03-24
1161 posts

Certainly! Best of luck smile

 Signature 

@ErikReagan
GitHub Repos
Focus Lab, LLC
EE Pro Network