admin管理员组文章数量:1335438
I write a custom plugin, with one link for administration purpose. This is my code:
add_action('admin_menu', 'tb_instructor_menu');
add_action( 'init', 'aggiungi_ruolo', 11 );
function aggiungi_ruolo()
{
$role = get_role( 'wdm_instructor' );
$role->add_cap( 'view_webinar', true );
}
function tb_instructor_menu()
{
add_menu_page('My code', 'My code', 'view_webinar', 'my-code', null, 'dashicons-businessman' , 61);
}
If I am logged in as Admin, I see the link.
If I'm logged in as "wdm_instructor", I don't see the link.
I have already verified that the "wdm_instructor" role has the "view_webinar" capability flagged.
I write a custom plugin, with one link for administration purpose. This is my code:
add_action('admin_menu', 'tb_instructor_menu');
add_action( 'init', 'aggiungi_ruolo', 11 );
function aggiungi_ruolo()
{
$role = get_role( 'wdm_instructor' );
$role->add_cap( 'view_webinar', true );
}
function tb_instructor_menu()
{
add_menu_page('My code', 'My code', 'view_webinar', 'my-code', null, 'dashicons-businessman' , 61);
}
If I am logged in as Admin, I see the link.
If I'm logged in as "wdm_instructor", I don't see the link.
I have already verified that the "wdm_instructor" role has the "view_webinar" capability flagged.
Share Improve this question asked May 29, 2020 at 12:32 InfocurciInfocurci 1 5 |1 Answer
Reset to default 0I understand the problem. My customer had purchased a paid plugin that, on the action "admin_menu", scrolled through the entire global variable $menu and eliminated all the items that were not allowed by their plugin
unset( $menu[ $key ] );
本文标签: admin menuaddmenupage not show link for custom role
版权声明:本文标题:admin menu - add_menu_page not show link for custom role 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742378028a2463555.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
view_webinar
capability? Keep in mind that when you calladd_cap
it makes changes to the database, your code as it is will make an unnecessary database write on every single request/page/ajax/RSS/REST etc This might be related to your problem – Tom J Nowell ♦ Commented May 29, 2020 at 12:41null
? – Tom J Nowell ♦ Commented May 29, 2020 at 14:03aggiungi_ruolo
, you should not be adding the capability on every single request, it should only happen once – Tom J Nowell ♦ Commented Jun 1, 2020 at 8:54