Redirection of users away from wp-admin (but not administrators)

Here’s how I do this:

// if admin send them to the dashboard, otherwise leave them on the frontend
add_action('wp_login', 'rt_login_redirect', 10, 2);  //use this action if you want them to be redirected only after login but leave the ability to to to the dashboard later (ie changing profile or pw).
add_action( 'admin_init', 'rt_login_redirect' ); // use this action to completely dis-allow all others besides the admin to access the dashboard.
function rt_login_redirect($user_login, $user) {

    if  (!current_user_can('manage_options')) {
            wp_safe_redirect( home_url(), 302);
            exit();
    }
}

The main function checks if the users is an admin by checking if the users has the ability to manage options. If they don’t have that capability then the function will redirect them to the homepage. If they do they can stay on the backend.

The function is activated when someone try to take an action (as commented above) (chose an option based on what you want)