Be Studios

Intercontinental Design Firm

This is our knowledge center. Enjoy!

WordPress redirect Dashboard for non-admin users

Easy one: this function redirects any user that hasn`t administrator capabilities to que home page of your site, if they try to access wp-admin/

add_action('admin_menu', 'redirect_dashboard');  
function redirect_dashboard(){  
    if( !current_user_can('level_10') ){  
        if( preg_match('#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI']) && ('index.php' != $menu[$page][2]) ) wp_redirect(get_bloginfo('url'));   
    }   
}

Just include it to you theme's functions.php.