AJAX nonce with check_ajax_referer()

I want to use check_ajax_referer() to verify a WP_nonce field using AJAX. Here you can find my html element. <input type=”hidden” name=”login_nonce” value=”<?= wp_create_nonce(‘login_nonce’); ?>”/> Using jQuery I’m sending all the values from input fields to a POST request: request = $.ajax({ type: ‘POST’, url: ‘handle-login.php’, data: { user: $(‘input[name=”login_username”]’).val(), pass: $(‘input[name=”login_password”]’).val(), security: $(‘input[name=”login_nonce”]’).val() }, … Read more

How do I create a user using the new JSON api in 4.7?

I formerly had the JSON API and JSON USER API plugins working before 4.7 and I have seen the documentation at the ReST API User reference, https://developer.wordpress.org/rest-api/reference/users/#create-a-user%20%22ReST%20API%20reference but I don’t know how to get started. I’m sure there is an authentication procedure that must happen first to get a nonce, but I don’t know how … Read more

Nonces and Cache

It’s clear that form submissions and AJAX requests, especially sensible ones, need “nonces” to avoid certain exploits. However, with heavy use of caching systems it becomes harder to generate them and output fresh nonces instead of cached ones. To solve the problem I thought about creating an AJAX function that returns a fresh nonce, to … Read more

How to expire a nonce?

I am aware of the fact that we can alter nonce life time using filter , 30 seconds here: add_filter( ‘nonce_life’, function () { return 30; } ); I have a logout() function for my rest api .I wish to expire a nonce that i created after successful login :$nonce = wp_create_nonce( ‘login’.$user_id ); 1 … Read more