WP_Query bug in wp_ajax action
-
Hello team,
– There is a problem with Instructor’s capabilities in your plugin.
When query courses in wp_ajax action, your query auto append current logged author id and posts of the authors.Please check and fix it soon.
Note: this happinng when you logged in as Instructor user.
Code Reference:
add_action( 'wp_ajax_get_simple_courses', 'simple_ajax_call' ); add_action( 'wp_ajax_nopriv_get_simple_courses', 'simple_ajax_call' ); function simple_ajax_call() { $query_args = [ 'post_type' => 'courses', 'posts_per_page' => 10, 'post_status' => 'publish', ]; $query = new WP_Query( $query_args ); /** * Logged in with Instructor have ID = 6. * * This is value of $query->request * SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'courses' AND ((wp_posts.post_status = 'publish')) AND ( wp_posts.post_author = 6 OR wp_posts.ID IN(208,209,210,211,212,213,214,215,205) ) ORDER BY wp_posts.post_date DESC LIMIT 0, 10 */ wp_die(); }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘WP_Query bug in wp_ajax action’ is closed to new replies.