WordPress 403 error on form submission with Ajax

the issue was to do with cookies. In a multi-site setup, the cookies that are set upon user login depends on which subsite the user logged in from; not all cookies give equal authority to submit forms. so the solution is either you (a) change your cookie domain to one common one in wp_config.php – … Read more

How to return a record from a custom table by sending an AJAX request

Your code (both client-side and server-side) makes no sense and is very ugly. You’re not loading WordPress in your custom PHP script, so there’s no way $wpdb would work. To call a method of an object, you should do $wpdb->get_results(‘… sql …’). You shouldn’t call PHP scripts directly anyway. It’s better to create a REST … Read more

How to use wp_ajax_set_post_thumbnail?

Assuming you’re looking at calling this via an AJAX style call from your browser, I’d suggest you look at the new WordPress REST API. Here’s the docs for the endpoint for updating posts. This will allow you to do exactly the same thing with the featured_media parameter, and much more, and is likely much better … Read more