How to pass array from jQuery to PHP with AJAX in WordPress?

If assign_categories() is in a class, you have to call the action in a different way. add_action( ‘wp_ajax_assign_categories’, ‘assign_categories’ ); becomes add_action( ‘wp_ajax_assign_categories’, array( $this, ‘assign_categories’ ) ); The $this in this context is the class.

Assign author on ajax wp post insert

You’re almost there. Here’s the part that is setting the author of post to user with ID = 1: ‘post_author’ => 1, ‘post_status’ => ‘publish’, ‘post_type’ => ‘testimonial’, ‘author’ => $current_user->ID, You even try to set the author to $current_user, but you don’t initiate this variable anywhere in your code and you set author field … Read more

AJAX update fails for public/non-admin users

Alright, I came across another answer that’s finally solved this. I had a function (in functions.php) which revoked admin access to some user types I’d created with custom privileges – that was blocking non-admin access to admin-ajax.php. Old/new function below: Old function // Revoke dashboard access add_action(‘admin_init’, ‘restrict_access_admin_panel’); function restrict_access_admin_panel(){ global $current_user; get_currentuserinfo(); if ($current_user->user_level … Read more