* Filter the form fields
* @since 1.0.0
* @param (array)     the fields
* @param (string)     location
* @return (array)     the fields

With this filter you can alter the fields of the ticket create form. The first parameter contains the existing fields. The second parameter tells you something about the location, where the fields will be displayed.

$location can have the value shortcode, which indicates, the shortcode is displayed, edit, which indicates, the field is needed to be displayed in the plugin settings and admin, which indicates, the field will be shown in the admin area.

A form field is an array like this one:

'label’        => __( 'Message’, 'sts’ ),
'id’        => 'ticket-message’,
'tag’        => 'textarea’,
'name’        => 'message’,
'value’        => ”,
'error’        => false,
'required’    => false


The 'tag'-parameter decides, which kind of input field will be displayed. Possible values are 'textarea', 'input', 'select' and 'html'. For the ‘select’[/code] value, you will need to provide a ‘choices’[/code]-parameter with the possible choices. For example:

'choices’ => array( 'value-1’ => 'Option 1’, 'value-2’ => 'Option 2’ )

If the ‘html’ is the value of the 'tag'-parameter you have to provide the 'html'-parameter. With this you can completly controll the output of the field.


Example: Creating a select field

add_filter( 'sts-create-ticket-formfields’, 'create_new_select’, 10, 2 );
function create_new_select( $fields, $type ){
$fields[] =  array(
'value’        => ”,
'label’        => 'Select field’,
'tag’        => 'select’,
'name’        => 'select-name’,
'id’        => 'select-id’,
'choices’    => array(
'1’    => 'Label 1’,
'2’    => 'Label 2’,
'3’    => 'Label 3’,
return $fields;

Related: sts-render-form-field