Restrict ADMIN menu items based on username, replace username with an actual user’s name.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | function remove_menus() { global $menu; global $current_user; get_currentuserinfo(); if($current_user->user_login == 'username') { $restricted = array(__('Posts'), __('Media'), __('Links'), __('Pages'), __('Comments'), __('Appearance'), __('Plugins'), __('Users'), __('Tools'), __('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)]); } } // end while } // end if } add_action('admin_menu', 'remove_menus'); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.