[英]Remove Site Stats and Elementor widgets from wordpress dashboard
我想針對特定用戶從儀表板上刪除以下兩個小部件。 1.網站統計2.要素概述
我未成功搜索以獲取小部件ID。 這是我的代碼:
add_action( 'admin_init', 'remove_widgets' );
function remove_widgets($query) {
if(!current_user_can('activate_plugins')) {
/* these don't seem to be working */
remove_meta_box( 'e-dashboard-overview', 'dashboard', 'normal');
unregister_widget('WP_Statistics');
}
}
將操作更改為“ wp_dashboard_setup”(而不是“ admin_init”)。
Elementor儀表板的代碼是正確的-我無法回答網站統計信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.