400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
I think the only thing missing here is that you need to move add_action(‘wp_ajax_nopriv_ajaxlogin’,’ajax_login’); outside ajax_login_init. That code registers your Ajax handler, but when you only run it on wp_enqueue_scripts, it’s already too late and wp_ajax_nopriv_ hooks are already run. So, have you tried something like this: function ajax_login_init(){ if ( ! is_user_logged_in() || ! … Read more