Submission Events

Hook into Submission events to attach your own logic for when submissions are being created, edited or deleted.

Before a submission is submitted

This event is called right before the submission is saved to the database.

use Solspace\Freeform\Services\SubmissionsService;
use Solspace\Freeform\Events\Submissions\SubmitEvent;

Event::on(
  SubmissionsService::class,
  SubmissionsService::EVENT_BEFORE_SUBMIT,
  function (SubmitEvent $event) {
    $form = $event->getForm();
    $submission = $event->getElement();

    // Perform manipulations here
  }
)
1
2
3
4
5
6
7
8
9
10
11
12
13

After a submission is submitted

This event is called right after the submission is saved to the database.

use Solspace\Freeform\Services\SubmissionsService;
use Solspace\Freeform\Events\Submissions\SubmitEvent;

Event::on(
  SubmissionsService::class,
  SubmissionsService::EVENT_AFTER_SUBMIT,
  function (SubmitEvent $event) {
    $form = $event->getForm();
    $submission = $event->getElement();

    // Perform some actions here
  }
)
1
2
3
4
5
6
7
8
9
10
11
12
13

Before a submission is deleted

use Solspace\Freeform\Services\SubmissionsService;
use Solspace\Freeform\Events\Submissions\DeleteEvent;

Event::on(
  SubmissionsService::class,
  SubmissionsService::EVENT_BEFORE_DELETE,
  function (DeleteEvent $event) {
    $submission = $event->getSubmission();
  }
)
1
2
3
4
5
6
7
8
9
10

After a submission is deleted

use Solspace\Freeform\Services\SubmissionsService;
use Solspace\Freeform\Events\Submissions\DeleteEvent;

Event::on(
  SubmissionsService::class,
  SubmissionsService::EVENT_AFTER_DELETE,
  function (DeleteEvent $event) {
    $submission = $event->getSubmission();
  }
)
1
2
3
4
5
6
7
8
9
10

Before a submission is updated in CP

use Solspace\Freeform\Controllers\SubmissionsController;
use Solspace\Freeform\Events\Submissions\UpdateEvent;

Event::on(
  SubmissionsController::class,
  SubmissionsController::EVENT_BEFORE_UPDATE,
  function (UpdateEvent $event) {
    $submission = $event->getSubmission();
  }
)
1
2
3
4
5
6
7
8
9
10

After a submission is updated in CP

use Solspace\Freeform\Controllers\SubmissionsController;
use Solspace\Freeform\Events\Submissions\UpdateEvent;

Event::on(
  SubmissionsController::class,
  SubmissionsController::EVENT_AFTER_UPDATE,
  function (UpdateEvent $event) {
    $submission = $event->getSubmission();
  }
)
1
2
3
4
5
6
7
8
9
10
Last Updated: 4/27/2020, 4:32:42 AM