Developers: Working with PHP Scripts
Heads up! We may offer PHP snippets as a courtesy but don’t provide support for code customizations.
Sometimes, you’d like to silently post data to an external URL after a popup closes, display content fetched from the database, or modify a box option before it’s displayed to the visitor.
With the PHP Scripts feature, all the aforementioned scenarios are now possible. Let’s see how that works.
FireBox fires certain events during runtime and enables you to execute PHP when these events occur, just like in the Actions section, but this time, the events are fired on the server side. With the proper knowledge of PHP, you can do just about anything and customize the behavior of the popup to fit your needs.
Prerequisites
Before using PHP Scripts, you must first enable them under FireBox > Settings > Advanced > Enable PHP Scripts.
Events
The PHP Scripts area explains what type of events are triggered by FireBox, letting you execute your own code and manipulate the behavior of your campaign.
On Before Render
The PHP script added in this area is executed after the campaign passes the Display Conditions checks and before the campaign’s layout is rendered. The main focus in this area is the $campaign (Object) variable, which contains the campaign’s settings.
On After Render
The PHP script added in this area is executed after the campaign’s layout is rendered. The main focus in this area is the $campaignLayout (String) variable, which contains the campaign’s final HTML. To access the campaign settings, use the $campaign (Object) variable.
On Open
The PHP script added to this area is executed every time the campaign opens. The main focus in this area is the $campaign (Object) variable, which contains the campaign’s settings.
On Close
The PHP script added in this area is executed every time the campaign is closed. The main focus in this area is the $campaign (Object) variable, which contains the campaign’s settings.
On Form Process
The PHP script added in this area is executed just before the FireBox – Form block has been saved into the database regardless if the submission is valid or not. This is rather helpful when you want to process calculations, make advanced validations or modify the value of a field. The main focus in this area is the $campaign (Object) variable which contains the campaign’s settings, $values (Array) variable which contains the submitted form field values, and $form_id (Integer) which contains the form id.
On Form Success
The PHP script added in this area is executed every time a visitor successfully submits the FireBox form block in your campaign. The main focus in this area is the $campaign (Object) variable, which contains the campaign’s settings, $values (Array), which contains the submitted form field values, and $submission (Array), which includes the submission details.