[wp-trac] [WordPress Trac] #41744: wp_insert_post() function doesn`t set the taxonomies from AJAX call

WordPress Trac noreply at wordpress.org
Mon Aug 28 15:54:46 UTC 2017


#41744: wp_insert_post() function doesn`t set the taxonomies from AJAX call
-------------------------------+------------------------
 Reporter:  WeddyWood          |       Owner:
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:
 Severity:  normal             |  Resolution:  duplicate
 Keywords:                     |     Focuses:
-------------------------------+------------------------

Comment (by WeddyWood):

 Replying to [comment:1 joyously]:
 > > `current_user_can()` does not work with AJAX
 >
 > That's a broad statement (AJAX is generic). If you use the REST API, you
 have to do authentication differently than if you use an ajax_action hook.
 The ajax_action hooks will only work from the WP site because of the
 authentication cookies. Those ajax_action hooks can (and do in core admin
 pages) use `current_user_can()`.
 >
 > Could you explain a test case?


 I expressed inaccurately. Function current_user_can() does not work
 (return false) when parent function wp_insert_post() was called by not-
 logged-in user. through 'wp_ajax_nopriv' hook

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41744#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list