function insert_timeticket() { $device_id = $_POST['device_id']; $duration = $_POST['duration']; $user_id = $_POST['user_id']; $ticket_id = $_POST['ticket_id']; $start_time = current_time('timestamp'); $end_time = current_time('timestamp') + 60 * $duration; $post_information = array('post_title' => fablab_get_captions('time_ticket_caption') . ' von: ' . get_user_by('id', $user_id)->display_name, 'post_type' => 'timeticket', 'author' => $user_id, 'post_status' => 'publish'); $ID = wp_insert_post($post_information); if ($ID != 0) { add_post_meta($ID, 'timeticket_device', $device_id); add_post_meta($ID, 'timeticket_start_time', $start_time); add_post_meta($ID, 'timeticket_end_time', $end_time); add_post_meta($ID, 'timeticket_user', $user_id); } deactivate_ticket($ticket_id); set_activation_time($ticket_id); die($ID != 0); }
function check_and_activate_ticket($ticket_id, $waiting_time) { if ($waiting_time == 0 && get_post_status($ticket_id) == 'publish') { set_activation_time($ticket_id); } }