Remove dashboard widgets according to user role

Remove dashboard widgets according to user role

If you’re owning a multi-user blog, it may be useful to know how to hide some dashboard widgets to keep confidential information in a safe place.

The following code will remove the postcustom meta box for “author” (role 2). To apply the hack on your own blog, just copy the code below and paste it in your functions.php file.

function customize_meta_boxes() {

//retrieve current user info

global $current_user;

get_currentuserinfo();

//if current user level is less than 3, remove the postcustom meta box

if ($current_user->user_level < 3) remove_meta_box(‘postcustom’,’post’,’normal’); } add_action(‘admin_init’,’customize_meta_boxes’);