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');

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)