A newer version of

Freeform

is available.

Try Freeform 5 now →

Freeform Freeform for Craft

Developer Events

Post Forwarding

Modify the POST payload

Use this event to add/remove things to the posted payload or make modifications to the Guzzle Client and Request objects.

use Solspace\Freeform\Bundles\Form\PayloadForwarding\PayloadForwarding;
use Solspace\Freeform\Events\PayloadForwarding\PayloadForwardEvent;

Event::on(
    PayloadForwarding::class,
    PayloadForwarding::EVENT_POST_FORWARDING,
    function (PayloadForwardEvent $event) {
        // Get the existing payload
        $payload = $event->getPayload();

        // Add something to it
        $payload['addedThing'] = 'This is an added thing';
        
        // Remove several of the default items from it
        unset(
            $payload['submission-id'], 
            $payload['submission-token'],
            $payload['submission-title']
        );

        // Persist our new changes in the event
        $event->setPayload($payload);
    }
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24