Stop ajax listener from sending empty parameter to function

I ended up just abstracting the actual validation to another function: function ajax_checkEmailAddress($passedEmail = false) { $sentEmail = sanitize_email($_POST[’email’], true); $jsonArray = validateEmailAddress($passedEmail); wp_send_json($jsonArray); } add_action(‘wp_ajax_checkEmailAddress’, ‘ajax_checkEmailAddress’); add_action(‘wp_ajax_nopriv_checkEmailAddress’, ‘ajax_checkEmailAddress’); function validateEmailAddress($email) { if (email_exists($email)) { $jsonArray[‘response’] = ‘error’; $jsonArray[‘message’] = __(‘This email address is already in use.’, ‘ajaxSignup’); } else { $jsonArray[‘response’] = ‘success’; } … Read more

Refresh table data with Ajax

In wordpress you need to use ajax in a specific way to follow the standard https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action) create a function in your functions.php file to handle the data retrieval and/or display of the table and add a hook to wp_ajax_(fires only for logged in users) and wp_ajax_nopriv_(fires for guests as well) add_action( ‘wp_ajax_add_foobar’, ‘prefix_ajax_add_foobar’ ); add_action( … Read more