No privilege ajax not working after WordPress update
-
Hi,
I’m working on local host Linux machine.
I’m having a strange problem; until yesterday before I updated WordPress to the 5.8.1 version I din’t have any problem with ajax for non privileged user, it worked fine.
The logged-in user still work fine today…
Now any non-privilege ajax call return an error.
to do the ajax call I use Jquery:function myJavascripFunction(){ var foo = 'foo'; jQuery(document).ready( function($) { $.ajax( { method : 'POST', dataType : 'json', url : my_var.ajaxurl, data : { foo : foo, _wpnonce : my_var.nonce, action : 'my_php_ajax_function' } } ) .done( function( data ){ console.log(data); } ); } ); }
on the php side I use a function that looks like this:
add_action( 'wp_ajax_nopriv_my_php_ajax_function', 'my_php_ajax_function' ); function my_php_ajax_function(){ if ( wp_verify_nonce( $_POST['_wpnonce'], 'wp_rest' ) ){ echo json_encode( array( 'foo' => $_POST['foo'] ) ); exit; } else { exit; } }
Does anyone has the same problem?
Any Idea?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘No privilege ajax not working after WordPress update’ is closed to new replies.