redirect out of wp-admin, without losing admin-ajax.php
Check the DOING_AJAX constant: function my_admin_init(){ if( !defined(‘DOING_AJAX’) && !current_user_can(‘administrator’) ){ wp_redirect( home_url() ); exit(); } } add_action(‘admin_init’,’my_admin_init’);