How to add custom fields to Support Press

It seems to be a common question on how to add custom fields to the WooThemes SupportPress. Please backup your files before making this modification, I also take no responsibility for any damage or adverse effect.

  1.  Edit the ‘theme-functions.php’, search for the  function woo_supportpress_get_ticket_details( $post_id )
    Add the ‘ticketextrafield1’ into the array
    $ticket_details = array(
    'status' => $status
    ,'type' => $type
    ,'priority' => $priority
    ,'assigned_to' => get_user_by('id', get_post_meta( $post_id, '_responsible', true))
    ,'reported_by' => get_post_meta( $post_id, '_reported_by', true)
    ,'reported_by_email' => get_post_meta( $post_id, '_reported_by_email', true)
    ,'ticketextrafield1' => get_post_meta( $post_id, '_ticketextrafield1', true)
  2. Now edit ‘theme-ticket-options.php’, search for function supportpress_ticket_meta() and edit a form input and HTML to the table.
    <th class="woo_metabox_names">
    <label for="woothemes__responsible">Extra Field 1</label>
    <textarea rows="8" cols="80" class="woo_input_textbox" id="_ticketextrafield1" name="_ticketextrafield1"/>
    <?php echo $ticket_details['ticketextrafield1'] ?>
  3. In the same file search for the function supportpress_ticket_meta_save( $post_id, $post )  add in the Custom field to the $data array
    // Get Post Data
    $data['ticket_status'] = stripslashes( $_POST['ticket_status'] );
    $data['ticket_priority'] = stripslashes( $_POST['ticket_priority'] );
    $data['ticket_type'] = stripslashes( $_POST['ticket_type'] );
    $data['_responsible'] = stripslashes( $_POST['_responsible'] );
    //Extra Fields
    $data['_ticketextrafield1'] = stripslashes( $_POST['_ticketextrafield1'] );
  4. To Display the custom field on the front facing Ticket Page, edit the Single-Ticket.php add in the following HTML and PHP code
    <h3>Extra Field</h3>
    <?php echo $ticket_details['ticketextrafield1']; ?>
    </article><!-- .post -->
Posted in SupportPress | 1 Comment