Example #1
0
 /**
  * Create a fresh ticket via the front-end form submission.
  * Checks for valid permissions, then gathers
  * the information, and creates a new post.
  *
  * @since Quality Control 0.1
  * @returns string $message An error or success message.
  */
 function quality_add_ticket()
 {
     global $quality_options, $current_user;
     if (!isset($_POST['create_ticket'])) {
         return false;
     }
     if (!quality_ticket_creation_cap()) {
         return apply_filters('quality_ticket_cap_notice', __('Sorry, you do not have permission to create a ticket', 'quality'));
     }
     $ticket = array();
     foreach ($_POST as $key => $value) {
         $ticket[$key] = isset($value) ? $value : "";
     }
     get_currentuserinfo();
     $ticket['ticket_author'] = $current_user->ID;
     if (!empty($ticket['ticket_title']) && !empty($ticket['comment'])) {
         $args = array('post_type' => 'ticket', 'post_status' => 'publish', 'comment_status' => 'open', 'post_category' => array($ticket['ticket_category']), 'tags_input' => $ticket['ticket_tags'], 'post_content' => $ticket['comment'], 'post_title' => $ticket['ticket_title'], 'post_author' => $ticket['ticket_author']);
         $args = apply_filters('quality_ticket_args', $args);
         $ticket_id = wp_insert_post($args);
         do_action('quality_insert_ticket', $ticket_id, $ticket);
         $message = apply_filters('quality_ticket_created', sprintf(__('Cool, your ticket was added. <a href="%s">View Ticket</a> or <a href="%s">Add Another</a>', 'quality'), get_permalink($ticket->ID), get_permalink($quality_options['ticket_page'])));
     } else {
         $message = apply_filters('quality_create_ticket_fields', __('Please fill out all required information.', 'quality'));
     }
     return $message;
 }
					
					<div id="create-ticket" class="panel">
									
						<div class="entry inner">
							<h1><?php 
        the_title();
        ?>
</h1>
							
							<?php 
        the_content();
        ?>
						</div>
						
						<?php 
        if (quality_ticket_creation_cap()) {
            ?>
						
							<div id="respond">
							
								<?php 
            if (quality_adding_ticket()) {
                ?>
								
									<div id="message" style="margin:0;"><?php 
                echo quality_add_ticket();
                ?>
</div>
										<br />
									
								<?php