'WordPress - Remove dashboard and edit menu items for logged in users
I want to create a private wordpress website where subscribers will be able to login and upload/manage only their uploads. How I can force the user to see the login / registration pages?
I've this code in my function file to remove the dashboard. I need a way to rename wp menu voices and icons and show only profile and upload after login.
function remove_menus () {
global $menu;
$restricted = array(__('Dashboard'));
//$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
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_menus');
function dashboard_redirect($url) {
global $current_user;
// is there a user ?
if(is_array($current_user->roles)) {
// check, whether user has the author role:
if(in_array('author', $current_user->roles)) {
$url = admin_url('edit.php?post_type=page');
}
return $url;
}
}
add_filter('login_redirect', 'dashboard_redirect');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
