WP Multisite with Domain Mapping : Preventing User Access to Dashboard

The file functions.php is not the place to run this kind of code. See Where do I put the code snippets I found here or somewhere else on the web?

You can use a Must Use plugin or make a simple one and Network Activate.

It would go like this:

<?php
/* Plugin Name: Only admins on dashboard */

add_action( 'admin_init', 'admin_ban_wpse_105863' );

function admin_ban_wpse_105863()
{
    if( !current_user_can( 'activate_plugins' ) ){
        wp_redirect( site_url() );
        exit;
    }
}

The documentation for the function get_bloginfo has recommended alternatives for many cases. The site_url function takes care of using the current blog URL.


[update]
The only place where the error message ...permissions to access... appears is in the file wp-admin/includes/menu.php. And it has an useful hook:

add_action( 'admin_page_access_denied', 'denied_ban_wpse_105863' );

function denied_ban_wpse_105863()
{
    wp_redirect( site_url() );
    exit;
}