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
- theForm
object
freeform_next_form_after_submit
#- Called after submitting a form.
- Contains these parameters:
form
- theForm
objectsubmission
- theSubmissionModel
object if the form is set to store data
freeform_next_form_before_save
#- Called before saving a form.
- Contains these parameters:
model
- theFormModel
isNew
- boolean value
freeform_next_form_after_save
#- Called after saving a form.
- Contains these parameters:
model
- theFormModel
isNew
- boolean value
freeform_next_form_before_delete
#- Called before deleting a form.
- Contains these parameters:
model
- theFormModel
freeform_next_form_after_delete
#- Called after deleting a form.
- Contains these parameters:
model
- theFormModel
Hooks for Freeform Submissions
freeform_next_submission_before_save
#- Called before saving a submission.
- Contains these parameters:
model
- theSubmissionModel
isNew
- boolean value
freeform_next_submission_after_save
#- Called after saving a submission.
- Contains these parameters:
model
- theSubmissionModel
isNew
- boolean value
freeform_next_submission_before_delete
#- Called before deleting a submission.
- Contains these parameters:
model
- theSubmissionModel
freeform_next_submission_after_delete
#- Called after deleting a submission.
- Contains these parameters:
model
- theSubmissionModel
Hooks for Freeform Fields
freeform_next_field_before_save
#- Called before saving a field.
- Contains these parameters:
model
- theFieldModel
isNew
- boolean value
freeform_next_field_after_save
#- Called after saving a field.
- Contains these parameters:
model
- theFieldModel
isNew
- boolean value
freeform_next_field_before_delete
#- Called before deleting a field.
- Contains these parameters:
model
- theFieldModel
freeform_next_field_after_delete
#- Called after deleting a field.
- Contains these parameters:
model
- theFieldModel
Hooks for Freeform Notifications
freeform_next_notification_before_save
#- Called before saving a notification.
- Contains these parameters:
model
- theNotificationModel
isNew
- boolean value
freeform_next_notification_after_save
#- Called after saving a notification.
- Contains these parameters:
model
- theNotificationModel
isNew
- boolean value
freeform_next_notification_before_delete
#- Called before deleting a notification.
- Contains these parameters:
model
- theNotificationModel
freeform_next_notification_after_delete
#- Called after deleting a notification.
- Contains these parameters:
model
- theNotificationModel
Hooks for Freeform Statuses
freeform_next_status_before_save
#- Called before saving a status.
- Contains these parameters:
model
- theStatusModel
isNew
- boolean value
freeform_next_status_after_save
#- Called after saving a status.
- Contains these parameters:
model
- theStatusModel
isNew
- boolean value
freeform_next_status_before_delete
#- Called before deleting a status.
- Contains these parameters:
model
- theStatusModel
freeform_next_status_after_delete
#- Called after deleting a status.
- Contains these parameters:
model
- theStatusModel
Hooks for Freeform File Uploads
freeform_next_file_before_upload
#- Called before uploading a file.
- Contains these parameters:
field
- theFileUploadField
freeform_next_file_after_upload
#- Called after uploading a file.
- Contains these parameters:
field
- theFileUploadField
fileId
- integer value
Hooks for Freeform Mailing
freeform_next_mailer_before_send
#- Called before sending an email.
- Contains these parameters:
notification
- theNotificationModel
submission
- theSubmissionModel
if data is being stored for this form
freeform_next_mailer_after_send
#- Called after sending an email.
- Contains these parameters:
isSent
- boolean valuenotification
- theNotificationModel
submission
- theSubmissionModel
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
- theIntegrationModel
isNew
- boolean value
freeform_next_crm_after_save
#- Called after saving an integration.
- Contains these parameters:
model
- theIntegrationModel
isNew
- boolean value
freeform_next_crm_before_delete
#- Called before deleting an integration.
- Contains these parameters:
model
- theIntegrationModel
freeform_next_crm_after_delete
#- Called after deleting an integration.
- Contains these parameters:
model
- theIntegrationModel
freeform_next_crm_before_push
#- Called before pushing data to an integration.
- Contains these parameters:
integration
- theAbstractIntegration
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
- theAbstractIntegration
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
- theIntegrationModel
isNew
- boolean value
freeform_next_mailing_lists_after_save
#- Called after saving an integration.
- Contains these parameters:
model
- theIntegrationModel
isNew
- boolean value
freeform_next_mailing_lists_before_delete
#- Called before deleting an integration.
- Contains these parameters:
model
- theIntegrationModel
freeform_next_mailing_lists_after_delete
#- Called after deleting an integration.
- Contains these parameters:
model
- theIntegrationModel
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
}
}