admin管理员组文章数量:1279238
When a user with Editor privileges logs in, they are bombarded with notices that they do not and should not care about.
How can I disable all nags for everyone except users with Administrator privileges?
When a user with Editor privileges logs in, they are bombarded with notices that they do not and should not care about.
How can I disable all nags for everyone except users with Administrator privileges?
Share Improve this question asked Sep 30, 2021 at 8:00 bobbob 2491 gold badge6 silver badges16 bronze badges1 Answer
Reset to default 1You could remove all actions from the admin_notices
hook. The best way to do that might be from the earliest priority of the hook itself, that way you catch any notices registered late.
add_action(
'admin_notices',
function() {
if ( ! current_user_can( 'manage_options' ) ) {
remove_all_actions( 'admin_notices' );
}
},
0
);
The problem is that there's very little standardisation around admin notices, and there could be plugins that are registering notices in the incorrect way or in the incorrect places. So if any notices aren't caught by that code, you'd need to address them on a case by case basis.
本文标签: dashboardHow can I programattically hide all admin notices for everyone except admin users
版权声明:本文标题:dashboard - How can I programattically hide all admin notices for everyone except admin users 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741293326a2370673.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论