Check if user is logged in via JS? [duplicate]
As you are going to send ajax request from theme (frontend) you need to specify the ajaxurl otherwise it will throw an error “undefined ajaurl” /** * frontend ajax requests. */ wp_enqueue_script( ‘frontend-ajax’, JS_DIR_URI . ‘frontend-ajax.js’, array(‘jquery’), null, true ); wp_localize_script( ‘frontend-ajax’, ‘frontend_ajax_object’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) ) ); then in your frontend-ajax.js … Read more