Filter WP user acf field by ajax

The problem is your action names don’t match In your frontend code: ?action=find_coach’; But in your backend code: add_action(‘wp_ajax_search_coach’, ‘searchLifeCoach’); add_action(‘wp_ajax_nopriv_search_coach’, ‘searchLifeCoach’); search_coach != find_coach, they have to match. Note that if this code used the REST API, it would have given a 404 and stated the problem in human readable language, e.g. { “code”:”rest_no_route”, … Read more

Can’t seem to get wp_localize_script to work

I tested that code like this: wp_enqueue_script(‘jquery’); wp_localize_script( ‘jquery’, ‘MS_Ajax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ), ‘nextNonce’ => wp_create_nonce( ‘myajax-next-nonce’ )) ); And it works but throws a Notice. It should be hooked to wp_enqueue_scripts like: function my_enqueue_scripts() { wp_enqueue_script(‘jquery’); wp_localize_script( ‘jquery’, ‘MS_Ajax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ), ‘nextNonce’ => wp_create_nonce( ‘myajax-next-nonce’ )) ); … Read more

help on wp_editor via ajax load [duplicate]

I’m not good with English, but the answer is that the editor class calls the scripts needed in the admin footer (wp-includes/class-wp-editor.php line 160) : add_action( ‘admin_print_footer_scripts’, array( __CLASS__, ‘editor_js’), 50 ); add_action( ‘admin_footer’, array( __CLASS__, ‘enqueue_scripts’), 1 ); So when you call the wp_editor function in your ajax, the scripts aren’t printed with it, … Read more

Issue with front-end ajax, getting a 302 redirect when accessing wp-admin/admin-ajax.php

Below function works for me by adding !defined(‘DOING_AJAX’) in condition. function custom_blockusers_init() { if ( is_admin() && !defined(‘DOING_AJAX’) && ( current_user_can(‘usercrp’) || current_user_can(‘userpcp’) || current_user_can(‘subscriber’) || current_user_can(‘contributor’) || current_user_can(‘editor’))) { session_destroy(); wp_logout(); wp_redirect( home_url() ); exit; } } add_action( ‘init’, ‘custom_blockusers_init’ );

Why is my AJAX call not working?

Okay so NOW I have the entire solution. It was two things: Caching was the first part of the issue. Cleared cache, deactivated caching plugin for the time-being. The second, less obvious issue was that, for NOT logged-in users, the response from the AJAX call was returning the entire HTML document in the response area. … Read more