×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Joseph Riviello
Added: Sep 12, 2012 4:16 PM
Views: 1764
Tags: no tags
  1. add_action('wp', 'gwiz_redirect');
  2. add_action('admin_init', 'gwiz_redirect');
  3. function gwiz_redirect() {
  4.    
  5.     $is_user_admin = current_user_can('administrator');
  6.    
  7.     // if admin, never redirect
  8.     if($is_user_admin)
  9.         return;
  10.    
  11.     // if it is not the admin
  12.     if(!is_admin())
  13.         return;
  14.    
  15.     // in all other cases, redirect
  16.     wp_redirect('http://xxx.com');
  17.     exit;    
  18. }