How do I remove dashboard access from specific user roles?

I’d like to prevent certain user roles from accessing the dashboard http://www.openeye.net/wp-admin/ at all. I’ve moved and restyled user profiles to a new page that’s viewable on the site. How would I go about doing this?

Solutions Collecting From Web of "How do I remove dashboard access from specific user roles?"

To lock subscribers and contributors out of the admin:

function wpse23007_redirect(){
  if( is_admin() && !defined('DOING_AJAX') && ( current_user_can('subscriber') || current_user_can('contributor') ) ){
    wp_redirect(home_url());
    exit;
  }
}
add_action('init','wpse23007_redirect');

Hope that helps. All roles give the user a capability that is the name of that role, so you can use any role name as a capability.

//If User Roll is Subscriber, It can not login in Dashboard 
function wpse23007_redirect()
{
    if( is_admin() && !defined('DOING_AJAX') && current_user_can('subscriber') )
    {
        wp_logout();
        wp_redirect(home_url());
        exit;
    }
}
add_action('init','wpse23007_redirect');

Yes, you would need to use the current_user_can( $capability ) function. Here is the official WordPress reference:
https://codex.wordpress.org/Function_Reference/current_user_can