
Berguna bila kita nak bagi public accout access wp-admin. Mungkin ada beberapa info yang tak perlu depa tau kita remove.
Example #1 using remove_meta_box :
add_action('wp_dashboard_setup','remove_dashboard_widgets");
function remove_jetpack(){
if ( ! current_user_can('manage_options') ){
remove_meta_box( 'dashboard_quick_press','dashboard', 'side' ); //Quick Press widget
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' ); //Recent Drafts
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); //WordPress.com Blog
remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' ); //Other WordPress News
remove_meta_box( 'dashboard_incoming_links','dashboard', 'normal' ); //Incoming Links
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' ); //Plugins
remove_meta_box('dashboard_right_now', 'dashboard', 'normal');
remove_meta_box('dashboard_activity', 'dashboard', 'normal');
remove_meta_box('tribe_dashboard_widget', 'dashboard', 'normal');
}
}
Example #2 using unset() :
add_action('wp_dashboard_setup','remove_dashboard_widgets");
function remove_jetpack(){
global $wp_meta_boxes;
if ( ! current_user_can('manage_options') ){
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
}
To disable all dashboard widget including custom widget we can do like this
add_action('wp_dashboard_setup','remove_dashboard_widgets");
function remove_jetpack(){
global $wp_meta_boxes;
if ( ! current_user_can('manage_options') ){
unset($wp_meta_boxes['dashboard']);
}
}