Extension Hooks
If you wish to extend the capabilities of Freeform, you can use any of the extension hooks below:
Forms
Before Submit
freeform_next_form_before_submit is called before submitting a form. Contains these parameters:
form- theFormobject
After Submit
freeform_next_form_after_submit is called after submitting a form. Contains these parameters:
form- theFormobjectsubmission- theSubmissionModelobject if the form is set to store data
Before Save
freeform_next_form_before_save is called before saving a form. Contains these parameters:
model- theFormModelisNew- boolean value
After Save
freeform_next_form_after_save is called after saving a form. Contains these parameters:
model- theFormModelisNew- boolean value
Before Delete
freeform_next_form_before_delete is called before deleting a form. Contains these parameters:
model- theFormModel
After Delete
freeform_next_form_after_delete is called after deleting a form. Contains these parameters:
model- theFormModel
Submissions
Before Save
freeform_next_submission_before_save is called before saving a submission. Contains these parameters:
model- theSubmissionModelisNew- boolean value
After Save
freeform_next_submission_after_save is called after saving a submission. Contains these parameters:
model- theSubmissionModelisNew- boolean value
Before Delete
freeform_next_submission_before_delete is called before deleting a submission. Contains these parameters:
model- theSubmissionModel
After Delete
freeform_next_submission_after_delete is called after deleting a submission. Contains these parameters:
model- theSubmissionModel
Fields
Before Save
freeform_next_field_before_save is called before saving a field. Contains these parameters:
model- theFieldModelisNew- boolean value
After Save
freeform_next_field_after_save is called after saving a field. Contains these parameters:
model- theFieldModelisNew- boolean value
Before Delete
freeform_next_field_before_delete is called before deleting a field. Contains these parameters:
model- theFieldModel
After Delete
freeform_next_field_after_delete is called after deleting a field. Contains these parameters:
model- theFieldModel
Notifications
Before Save
freeform_next_notification_before_save is called before saving a notification. Contains these parameters:
model- theNotificationModelisNew- boolean value
After Save
freeform_next_notification_after_save is called after saving a notification. Contains these parameters:
model- theNotificationModelisNew- boolean value
Before Delete
freeform_next_notification_before_delete is called before deleting a notification. Contains these parameters:
model- theNotificationModel
After Delete
freeform_next_notification_after_delete is called after deleting a notification. Contains these parameters:
model- theNotificationModel
Statuses
Before Save
freeform_next_status_before_save is called before saving a status. Contains these parameters:
model- theStatusModelisNew- boolean value
After Save
freeform_next_status_after_save is called after saving a status. Contains these parameters:
model- theStatusModelisNew- boolean value
Before Delete
freeform_next_status_before_delete is called before deleting a status. Contains these parameters:
model- theStatusModel
After Delete
freeform_next_status_after_delete is called after deleting a status. Contains these parameters:
model- theStatusModel
File Uploads
Before Upload
freeform_next_file_before_upload is called before uploading a file. Contains these parameters:
field- theFileUploadField
After Upload
freeform_next_file_after_upload is called after uploading a file. Contains these parameters:
field- theFileUploadFieldfileId- integer value
Mailing
Before Send
freeform_next_mailer_before_send is called before sending an email. Contains these parameters:
notification- theNotificationModelsubmission- theSubmissionModelif data is being stored for this form
After Send
freeform_next_mailer_after_send is called after sending an email. Contains these parameters:
isSent- boolean valuenotification- theNotificationModelsubmission- theSubmissionModelif data is being stored for this form
CRM Integrations
Before Save
freeform_next_crm_before_save is called before saving an integration. Contains these parameters:
model- theIntegrationModelisNew- boolean value
After Save
freeform_next_crm_after_save is called after saving an integration. Contains these parameters:
model- theIntegrationModelisNew- boolean value
Before Delete
freeform_next_crm_before_delete is called before deleting an integration. Contains these parameters:
model- theIntegrationModel
After Delete
freeform_next_crm_after_delete is called after deleting an integration. Contains these parameters:
model- theIntegrationModel
Before Push
freeform_next_crm_before_push is called before pushing data to an integration. Contains these parameters:
integration- theAbstractIntegrationvalues- a key-value object of all values to be pushed to the integration.
After Push
freeform_next_crm_after_push is called after pushing data to an integration. Contains these parameters:
integration- theAbstractIntegrationvalues- a key-value object of all values that were pushed to the integration.
Mailing-List Integrations
Before Save
freeform_next_mailing_lists_before_save is called before saving an integration. Contains these parameters:
model- theIntegrationModelisNew- boolean value
After Save
freeform_next_mailing_lists_after_save is called after saving an integration. Contains these parameters:
model- theIntegrationModelisNew- boolean value
Before Delete
freeform_next_mailing_lists_before_delete is called before deleting an integration. Contains these parameters:
model- theIntegrationModel
After Delete
freeform_next_mailing_lists_after_delete is called after deleting an integration. Contains these parameters:
model- theIntegrationModel
Usage instructions
Register any of the hooks listed above with your extension. An example below using the 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
}
}