function event_api_post_callback( $request ) {
global $event;
$event_data = array(
‘post_type’ => ‘tc_events’,
‘post_title’ => $request[‘event_name’],
‘post_content’ => $request[‘event_terms’],
‘post_status’ => ‘publish’
);
$events = new TC_Events();
$event = wp_insert_post( $event_data );
if( !is_wp_error($event_data) ) {
$response[‘status’] = 200;
$response[‘success’] = true;
update_post_meta( $event, ‘event_location’, $request[‘event_location’]);
update_post_meta( $event, ‘event_date_time’, $request[‘event_date_time’]);
update_post_meta( $event, ‘event_end_date_time’, $request[‘event_end_date_time’]);
update_post_meta( $event, ‘event_terms’, $request[‘genre’]);
update_post_meta( $event, ‘event_logo’, $request[‘event_logo’]);
wp_set_object_terms( $event, $request[‘event_category’], ‘event_category’ );
get_post_meta( $event, ‘tc_speakers’);
update_post_meta( $event, ‘tc_speakers’, $request[‘speaker_tags’]);
update_post_meta( $event, ‘tc_speakers_show_type’, ‘shortcode’);
update_post_meta( $event, ‘tc_speakers_view’, ‘tc_list’);
update_post_meta($event, ‘tc_speakers_grid_show_cats’, ‘no’);
update_post_meta($event, ‘event_datetime_utc’, $request[‘event_end_time_utc’]);
update_post_meta($event, ‘event_logo_file_url’, $request[‘timezone’]);
fifu_dev_set_image($event, ‘https://youbloomconnect.com/storage/event_photo/’.$request[‘event_logo’]);
$permalink = get_permalink($event);
$p_id = get_post($event);
$status = ‘draft’;
global $WOOCS;
$currencies=$WOOCS->get_currencies();
$converted_currency = $WOOCS->back_convert($request[‘price’],$currencies[$request[‘currency’]][‘rate’],0);
$response[‘permalink’] = $converted_currency;
$response[‘ID’] = $p_id;
$response[‘converted_currency’] = $converted_currency;
global $wpdb;
$where = array( ‘ID’ => $event );
$data = array(‘post_status’=>’draft’);
$wpdb->update( $wpdb->posts, $data, $where );
} else {
$response[‘status’] = 200;
$response[‘success’] = false;
$response[‘data’] = get_post( $events );
}
return new WP_REST_Response($response);
// }
}