I have customized a plugin to make some ajax calls to admin-ajax.php and it works great. I copied the code over to another site and it no longer works for users who are not logg
I had the exact same problem and this worked for me:
function mt_redirect_admin() { if ( ! current_user_can( 'manage_options' ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { wp_redirect( site_url() ); exit; } } add_action( 'admin_init', 'mt_redirect_admin', 1 );