This document is for an older version of

Freeform

.

View latest version →

Freeform Freeform for ExpressionEngine

Extension Hooks

If you wish to extend the capabilities of Freeform, you can use any of the extension hooks below:

Hooks for Freeform Forms

  • freeform_next_form_before_submit #
    • Called before submitting a form.
    • Contains these parameters:
      • form - the Form object
  • freeform_next_form_after_submit #
    • Called after submitting a form.
    • Contains these parameters:
      • form - the Form object
      • submission - the SubmissionModel object if the form is set to store data
  • freeform_next_form_before_save #
    • Called before saving a form.
    • Contains these parameters:
      • model - the FormModel
      • isNew - boolean value
  • freeform_next_form_after_save #
    • Called after saving a form.
    • Contains these parameters:
      • model - the FormModel
      • isNew - boolean value
  • freeform_next_form_before_delete #
    • Called before deleting a form.
    • Contains these parameters:
      • model - the FormModel
  • freeform_next_form_after_delete #
    • Called after deleting a form.
    • Contains these parameters:
      • model - the FormModel

Hooks for Freeform Submissions

  • freeform_next_submission_before_save #
    • Called before saving a submission.
    • Contains these parameters:
      • model - the SubmissionModel
      • isNew - boolean value
  • freeform_next_submission_after_save #
    • Called after saving a submission.
    • Contains these parameters:
      • model - the SubmissionModel
      • isNew - boolean value
  • freeform_next_submission_before_delete #
    • Called before deleting a submission.
    • Contains these parameters:
      • model - the SubmissionModel
  • freeform_next_submission_after_delete #
    • Called after deleting a submission.
    • Contains these parameters:
      • model - the SubmissionModel

Hooks for Freeform Fields

  • freeform_next_field_before_save #
    • Called before saving a field.
    • Contains these parameters:
      • model - the FieldModel
      • isNew - boolean value
  • freeform_next_field_after_save #
    • Called after saving a field.
    • Contains these parameters:
      • model - the FieldModel
      • isNew - boolean value
  • freeform_next_field_before_delete #
    • Called before deleting a field.
    • Contains these parameters:
      • model - the FieldModel
  • freeform_next_field_after_delete #
    • Called after deleting a field.
    • Contains these parameters:
      • model - the FieldModel

Hooks for Freeform Notifications

  • freeform_next_notification_before_save #
    • Called before saving a notification.
    • Contains these parameters:
      • model - the NotificationModel
      • isNew - boolean value
  • freeform_next_notification_after_save #
    • Called after saving a notification.
    • Contains these parameters:
      • model - the NotificationModel
      • isNew - boolean value
  • freeform_next_notification_before_delete #
    • Called before deleting a notification.
    • Contains these parameters:
      • model - the NotificationModel
  • freeform_next_notification_after_delete #
    • Called after deleting a notification.
    • Contains these parameters:
      • model - the NotificationModel

Hooks for Freeform Statuses

  • freeform_next_status_before_save #
    • Called before saving a status.
    • Contains these parameters:
      • model - the StatusModel
      • isNew - boolean value
  • freeform_next_status_after_save #
    • Called after saving a status.
    • Contains these parameters:
      • model - the StatusModel
      • isNew - boolean value
  • freeform_next_status_before_delete #
    • Called before deleting a status.
    • Contains these parameters:
      • model - the StatusModel
  • freeform_next_status_after_delete #
    • Called after deleting a status.
    • Contains these parameters:
      • model - the StatusModel

Hooks for Freeform File Uploads

  • freeform_next_file_before_upload #
    • Called before uploading a file.
    • Contains these parameters:
      • field - the FileUploadField
  • freeform_next_file_after_upload #
    • Called after uploading a file.
    • Contains these parameters:
      • field - the FileUploadField
      • fileId - integer value

Hooks for Freeform Mailing

  • freeform_next_mailer_before_send #
    • Called before sending an email.
    • Contains these parameters:
      • notification - the NotificationModel
      • submission - the SubmissionModel if data is being stored for this form
  • freeform_next_mailer_after_send #
    • Called after sending an email.
    • Contains these parameters:
      • isSent - boolean value
      • notification - the NotificationModel
      • submission - the SubmissionModel if data is being stored for this form

Hooks for Freeform CRM Integrations

  • freeform_next_crm_before_save #
    • Called before saving an integration.
    • Contains these parameters:
      • model - the IntegrationModel
      • isNew - boolean value
  • freeform_next_crm_after_save #
    • Called after saving an integration.
    • Contains these parameters:
      • model - the IntegrationModel
      • isNew - boolean value
  • freeform_next_crm_before_delete #
    • Called before deleting an integration.
    • Contains these parameters:
      • model - the IntegrationModel
  • freeform_next_crm_after_delete #
    • Called after deleting an integration.
    • Contains these parameters:
      • model - the IntegrationModel
  • freeform_next_crm_before_push #
    • Called before pushing data to an integration.
    • Contains these parameters:
      • integration - the AbstractIntegration
      • values - a key-value object of all values to be pushed to the integration.
  • freeform_next_crm_after_push #
    • Called after pushing data to an integration.
    • Contains these parameters:
      • integration - the AbstractIntegration
      • values - a key-value object of all values that were pushed to the integration.

Hooks for Freeform Mailing-List Integrations

  • freeform_next_mailing_lists_before_save #
    • Called before saving an integration.
    • Contains these parameters:
      • model - the IntegrationModel
      • isNew - boolean value
  • freeform_next_mailing_lists_after_save #
    • Called after saving an integration.
    • Contains these parameters:
      • model - the IntegrationModel
      • isNew - boolean value
  • freeform_next_mailing_lists_before_delete #
    • Called before deleting an integration.
    • Contains these parameters:
      • model - the IntegrationModel
  • freeform_next_mailing_lists_after_delete #
    • Called after deleting an integration.
    • Contains these parameters:
      • model - the IntegrationModel

Usage instructions

Register to any of the hooks listed above with your extension. An example below using freeform_next_form_before_save hook using form_before_save method in our example extension object:

<?php

use Solspace\Addons\FreeformNext\Model\FormModel;

class Example_ext
{
    // ... other code

    /**
     * Set all new Freeform forms to have random hash as their name and handle
     *
     * @param FormModel $model
     * @param bool      $isNew
     */
    public function form_before_save(FormModel $model, $isNew)
    {
        if ($isNew) {
            // Set the form's name and handle to some random hash
            $model->name = md5(time());
            $model->handle = $model->name;
        }

        // the model gets saved later on, no need to call save() here
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25