Adding New Fields to Help Scout Submission

In the below example a new field is added to the support ticket submission for via the
hd_form_message hook. After the submission the conversation is filtered and the field is added to the message body.

<?php // don't include this line in your functions.php, since it already starts with it.
/**
* Adds the website field to the ticket submission form
*
*/
function hsd_enter_website_field() {
$conversation_view = ( isset( $_GET['conversation_id'] ) && '' !== $_GET['conversation_id'] );
// only for new threads
if ( $conversation_view ) {
return;
}
?>
<div class="form-group">
<label for="hs_thread_website" class="hidden"><?php _e( 'Enter Website', 'help-scout-desk' ) ?></label>
<input type="text" name="hs_thread_website" id="hs_thread_website" class="form-control" required="required" placeholder="<?php _e( 'http://yoursite.com', 'help-scout-desk' ) ?>"/>
</div>
<?php
}
add_action( 'hsd_form_message', 'hsd_enter_website_field' );
/**
* Filter what is sent to Help Scout and add the website to the thread message.
* @param array $conversation The conversation array that is used to create the thread with Help Scout
* @return array Conversation array.
*/
function maybe_add_website_to_message_footer( $conversation = array() ) {
if ( ! isset( $_POST['hs_thread_website'] ) ) {
return $conversation;
}
if ( ! isset( $conversation['threads'][0]['text'] ) ) {
return $conversation;
}
$conversation['threads'][0]['text'] .= sprintf( __( '<p><b>Website:</b> %s</p>', 'help-scout-desk' ), $_POST['hs_thread_website'] ); // add website
return $conversation;
}
add_action( 'hsd_create_conversation_fields', 'maybe_add_website_to_message_footer' );

Adding your custom fields to the message body is the only viable solution since these “conversations” are essentially emails, and tags are used for the
conversation type. You can learn a bit more about this via the Help Scout v3.0 release post.