Developers: Working with PHP Scripts

Heads up! This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don’t provide support for code customizations or 3rd party development.

There are cases where you’d like to silently post data to an external URL after a popup closes, display content fetched from the database or even 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 types of events during runtime and enables you to execute PHP when these events occurred 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.

Events

The PHP Scripts area consits of the following 5 sections that are triggered on certain events.

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 $box (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 $boxLayout (String) variable which contains the final HTML of the campaign. To access the campaign settings use the $box (Object) variable. 

On Open

The PHP script added in this area is executed every time the campaign is opened. The main focus in this area is the $box (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 $box (Object) variable which contains the campaign’s settings.

On Form Success

The PHP script added in this area is executed every time a FireBox form block has been successfully submitted by a visitor on your site. The main focus in this area is the $box (Object) variable which contains the campaign’s settings, $values (Array) which contains the submitted form field values, and $submission (Array) which contains the submission details.

Examples

Example #1: Execute code when the submitted form ID is form-123.

if ($submission['form_id'] == 'form-123') {
    // your logic here
}
Was this helpful?
In this article
Quick navigation