I am working on converting some Formidable Forms to WS Form, and one feature that appears to be missing (at the time of this article) is the ability to send a raw data package using the Webhook option. It works as long as there is a one-to-one value, but if you need to send an array, I could find no out-of-the-box option. I turned to ChatGPT, and after recommending options that do not exist, it helped me tie into a filter that allows you to target the payload.

In this case, I have a form that allows users to open a GitHub issue and assign a label. The GitHub API expects an array for the “labels” value so that it is possible to assign more than one at a time. In my case, I only have one fixed value, but it still needs to be presented as an array. I may experiment with a multiselect option to pass multiple values.

add_filter( 'wsf_action_webhook_payload', 'modify_github_labels_payload', 10, 4 );

function modify_github_labels_payload( $payload, $form, $submit, $action ) {
    if ( isset( $payload['labels'] ) && is_string( $payload['labels'] ) ) {
        // Split the comma-separated string into an array
        $labels_array = array_map( 'trim', explode( ',', $payload['labels'] ) );
        $payload['labels'] = $labels_array;
    }
    return $payload;
}

I have sent this to the developer, and given his track record, I expect a native feature in short order, but in case I am wrong, I now have this to refer to.