Advertisement
Guest User

WP-Block Admin

a guest
Jul 23rd, 2010
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. if (is_user_logged_in() ) {
  2.         // Is this the admin interface?
  3.         if (
  4.             // Look for the presence of /wp-admin/ in the url
  5.             stripos($_SERVER['REQUEST_URI'],'/wp-admin/') !== false
  6.             ||
  7.             // Look for the presence of /wp-login.php/ in the url
  8.             stripos($_SERVER['REQUEST_URI'],'/wp-login.php') !== false
  9.             &&
  10.             // Allow calls to async-upload.php
  11.             stripos($_SERVER['REQUEST_URI'],'async-upload.php') == false
  12.             &&
  13.             // Allow calls to admin-ajax.php
  14.             stripos($_SERVER['REQUEST_URI'],'admin-ajax.php') == false
  15.    
  16.         ) {
  17.            
  18.             // Does the current user fail the required capability level?
  19.             if (!current_user_can($wpba_required_capability)) {
  20.             // If you want to use this plugin on WPMU to stop all users accessing the admin interface, comment out the line above, uncomment the line below.
  21. //          if (!is_site_admin()) {
  22.                
  23.                 // Do we need to default to the site homepage?
  24.                 if ($wpba_redirect_to == '') { $wpba_redirect_to = get_option('siteurl'); }
  25.                
  26.                 // Send a temporary redirect
  27.                 wp_redirect($wpba_redirect_to,302);
  28.                
  29.             }
  30.            
  31.         }
  32.        
  33.     }
  34.     }//end if logged in
  35.    
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement