WordPress Admin Page Redirected To Homepage

In this wordpress post, i added the sourcecode to redirect the page or denied the permission When the unauthorized user level will try to access the admin section. Using this sourcecode i am allowing administrator and editor to access the admin panel. Otherwise i am redirecting the user to home page. You can modify redirect url When access the admin panel. I allowed administrator and editor to access the admin section and denied the permission for contributor, author and subscriber. [gad]

Wordpress Redirect Function For Unauthorized User Level

Admin panel permission For:Editor(7), Administrator(10) Admin panle permission denied For:subscriber(0), contributor(1) and author(2)

function bsc_hide_admin_process(){
	global $user_level;
	if ($user_level == 0 || $user_level == 1 || $user_level == 2) {
        wp_redirect(get_option('siteurl'));
    }
}
add_action('admin_head', 'bsc_hide_admin_process');