hide menu
-
I was looking around for a way to hide the contact form menu from other users besides the admin and came across a topic with someone posting a function. It worked for me except it would remove it in my admin panel also. I figured out the problem so I thought I would share with those looking for a solution. Here is the code that someone posted
function remove_contact_menu () { global $menu; $restricted = array(__('Contact')); 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_contact_menu'); if(!current_user_can('level_10')) { add_action('admin_menu', 'remove_contact_menu'); }
What you have to do is remove
add_action('admin_menu', 'remove_contact_menu');
because there are 2 of the same code. all I did was remove the top code and it’s working fine.
So the final code is
function remove_contact_menu () { global $menu; $restricted = array(__('Contact')); end ($menu); while (prev($menu)){ $value = explode(' ',$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);} } } if ( ! current_user_can('level_10') ) { add_action('admin_menu', 'remove_contact_menu'); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘hide menu’ is closed to new replies.