From: Laury GvR Date: Wed, 25 Feb 2015 21:22:06 +0000 (-0500) Subject: Restrict admin side to editors and aministrators. Redirect to front page if not X-Git-Tag: v1.0.0^2~18 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=7ec5e5252a299b6e504e2b27769bf193120f5bca;p=WP-Themes%2FTomsMomsCookies.git Restrict admin side to editors and aministrators. Redirect to front page if not --- diff --git a/functions.php b/functions.php index 2e8e7c1..452f511 100755 --- a/functions.php +++ b/functions.php @@ -134,26 +134,17 @@ function custom_upload_mimes ( $existing_mimes=array() ) } function redirect_user_on_role() { - global $current_user; - get_currentuserinfo(); - - //If login user role is Subscriber - if ($current_user->user_level == 0) - { + if ( !current_user_can( 'manage_options' ) && (!current_user_can('publish_pages') ) ) { + /* A non-admin, non-editor */ wp_redirect( home_url() ); exit; } - + //If login user role is Subscriber + // if ($current_user->user_level !== 0) //If login user role is Contributor - if ($current_user->user_level > 1) - { - wp_redirect( home_url() ); exit; - } - + // if ($current_user->user_level > 1) //If login user role is Editor - if ($current_user->user_level > 8) - { -// wp_redirect( home_url() ); exit; - } + // if ($current_user->user_level > 8) + } add_action('admin_init', 'redirect_user_on_role');