Ideally, since the "Dashboard" submenu is gone for authors, I just want to replace it with a single link that pulls up the wp-admin home page.
Just re-enabling Dashboard>home would work well too.
[edit] Here is what I have now. I know this isn't the best way to do this, but I couldn't get "add_menu_page" do do it correctly. I manually edited the $menu variable.
This will work as a solution if I cannot find a better way.
add_action( 'admin_menu', function (){
if ( !current_user_can( 'administrator' ) ) {
global $menu;
$menu[0]=[
0 => 'Dashboard',
1 => 'read',
2 => 'index.php',
3 => '',
4 => 'menu-top menu-top-first menu-icon-dashboard',
5 => 'menu-dashboard',
6 => 'dashicons-dashboard',
];
}
});
Ideally, since the "Dashboard" submenu is gone for authors, I just want to replace it with a single link that pulls up the wp-admin home page.
Just re-enabling Dashboard>home would work well too.
[edit] Here is what I have now. I know this isn't the best way to do this, but I couldn't get "add_menu_page" do do it correctly. I manually edited the $menu variable.
This will work as a solution if I cannot find a better way.
add_action( 'admin_menu', function (){
if ( !current_user_can( 'administrator' ) ) {
global $menu;
$menu[0]=[
0 => 'Dashboard',
1 => 'read',
2 => 'index.php',
3 => '',
4 => 'menu-top menu-top-first menu-icon-dashboard',
5 => 'menu-dashboard',
6 => 'dashicons-dashboard',
];
}
});
Share
Improve this question
edited Apr 25, 2019 at 19:10
De Coder
asked Apr 25, 2019 at 6:01
De CoderDe Coder
3291 silver badge11 bronze badges
1
- I located where the theme author removed the menu via remove_menu_page() – De Coder Commented Apr 30, 2019 at 17:54
1 Answer
Reset to default 1It's not the menu you need to adjust - it's your roles and capabilities.
By default, a WP Core Author has "Dashboard" in their menu. You're correct, they do not have a submenu under Dashboard, but clicking Dashboard takes them to the same page as "Dashboard > Home" for other users.
You may want to look through whatever plugins you're using that may have adjusted permissions, and/or use a user role plugin to check what permissions users have. If they can't see "Dashboard" at all, they need "read" capability added:
// hook to admin init
add_action('admin_init', 'add_author_caps');
function add_author_caps() {
// get the author role
$role = get_role('author');
// add "read" capability
$role->add_cap('read');
}
You can add this temporarily wherever you like - theme or plugin - and after you've logged in and viewed anything in wp-admin, you can remove this code as WP will save the capability.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745551827a4632611.html
评论列表(0条)