Tag Archives: function

Administration Dashboard

I wrote a simple function for modifying the way the dashboard is shown for different user roles. For example I don’t want my subscribers too see all the system magic like stats:

// initiate the function
add_action( ‘wp_dashboard_setup’, ‘remove_dashboard_widgets’ );

function remove_dashboard_widgets() {

global $wp_meta_boxes;

// if a user cannot edit posts he or she will only see the latest comments
if ( ! current_user_can( ‘edit_posts’ ) ) {

unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_right_now’]);
unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_incoming_links’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_secondary’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_primary’]);

}

// if a user cannot update the core he or she will not see
// the wordpress news on the dashboard

if ( ! current_user_can( ‘update_core’ ) ) {

unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_secondary’]);
unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_primary’]);

}

}

 

More information on this can be found in the codex: http://codex.wordpress.org/Roles_and_Capabilities