- // Only accept categories if the user actually can assign
- $category_tax = get_taxonomy( 'category' );
- if ( current_user_can( $category_tax->cap->assign_terms ) ) {
- $post_data['post_category'] = ( ! empty( $_POST['post_category'] ) ) ? $_POST['post_category'] : array();
- }
-
- // Only accept taxonomies if the user can actually assign
- if ( ! empty( $_POST['tax_input'] ) ) {
- $tax_input = $_POST['tax_input'];
- foreach ( $tax_input as $tax => $_ti ) {
- $tax_object = get_taxonomy( $tax );
- if ( ! $tax_object || ! current_user_can( $tax_object->cap->assign_terms ) ) {
- unset( $tax_input[ $tax ] );
- }
- }
-
- $post_data['tax_input'] = $tax_input;
- }
-
- // Toggle status to pending if user cannot actually publish