admin管理员组文章数量:1431426
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.
本文标签: Login as nonadmin user removes Dashboard submenu I wish to reenable it
版权声明:本文标题:Login as non-admin user removes Dashboard submenu. I wish to re-enable it 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745551826a2662977.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论