We form a menu for an individual user
Sometimes when developing a site, you need to hide the admin panel menu items for an individual user, that's what we're going to do today. In order to change the rights to display the menu for individual users, let's try to write a special action.
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 |
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 don't want to deal with API WordPress, you can always use special plugins adminimize or Advanced Access Manager. The second plugin is more convenient, but it does not work correctly with all versions CMS WordPress, The functionality of the plugins is about the same.. Yes, and another important point, there is a very good plugin that you can buy, but it works fine with the other two Views Types Aaccess. I think it's a log to learn about these plugins, and it's up to you to choose. Good luck in website development.
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.