Skip the Dashboard for Chosen Roles
Sends users with certain roles straight to a more useful screen, like the Posts list, whenever they open the dashboard.
Opens WPIDE on
Code
// Role => admin page to open instead of the dashboard.
$wpide_dashboard_redirects = array(
'author' => 'edit.php',
'contributor' => 'edit.php',
'shop_manager' => 'admin.php?page=wc-orders',
);
add_action( 'load-index.php', function () use ( $wpide_dashboard_redirects ) {
$user = wp_get_current_user();
foreach ( (array) $user->roles as $role ) {
if ( isset( $wpide_dashboard_redirects[ $role ] ) ) {
wp_safe_redirect( admin_url( $wpide_dashboard_redirects[ $role ] ) );
exit;
}
}
} );
Notes
Administrators are never redirected unless you add the administrator role to the list.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.