Restricting Access to WordPress Menu Points in the Backend Based on the Username

<?php function ah_remove_menus() { global $menu; global $current_user; get_currentuserinfo(); if($current_user->user_login == 'username') // The 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', 'ah_remove_menus');
With this feature, you can deactivate the access to individual admin menu items based on the username.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.