Attempt to keep non-admin, non-editor users out of wp-admin
authorLaury GvR <laury@gaslightmedia.com>
Wed, 25 Feb 2015 21:07:55 +0000 (16:07 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 25 Feb 2015 21:07:55 +0000 (16:07 -0500)
functions.php

index c408bd7..2e8e7c1 100755 (executable)
@@ -131,6 +131,31 @@ function custom_upload_mimes ( $existing_mimes=array() )
     // Add *.AI files to Media upload 
     $existing_mimes['ai'] = 'application/postscript'; 
     return $existing_mimes; 
-} 
+}
+function redirect_user_on_role()
+{
+    global $current_user;
+    get_currentuserinfo();
+       
+    //If login user role is Subscriber
+    if ($current_user->user_level == 0)
+    {
+        wp_redirect( home_url() ); exit;
+    }
+
+    //If login user role is Contributor
+    if ($current_user->user_level > 1)
+    {
+        wp_redirect( home_url() ); exit;
+    }
+
+    //If login user role is Editor
+    if ($current_user->user_level > 8)
+    {
+//        wp_redirect( home_url() ); exit;
+    }
+}
+add_action('admin_init', 'redirect_user_on_role');
+
 ?>