GB Relay

Say hello to automation! GB Relay is designed to enhance your site's efficiency by allowing you to seamlessly trigger custom actions directly from extension hooks, such as syncing member details to HubSpot upon registration or distributing articles to subscription services post-publication. With the capability to create intricate chains of events, our addon ensures that follow-up actions, like saving reference IDs back into your content entries or updating the channel entry ID, are automated and hassle-free.

Installation

Upload the folders to the respective system/user/addons/ and themes/user/ directories, then click 'Install' on the Add-Ons page.

Settings

Request

Title (required)

cURL Options

Not all options are listed. For additional options not listed here, please contact me via direct message on the EE Slack channel or [email protected]. When using (PHP code) to return the value, omit the <?php open tag. Just remember to return the variable. IMPORTANT: (EE Template) may be a bit wonky, but generally speaking it should work.

CURLOPT_HTTPHEADER

This option does not take associative array (key-value pairs). Leave the key column empty and enter directly into the value column like Content-Type: application/json or Authorization: Bearer <token> to generate the indexed array to be attached.

Response Type

The add-on comes with JSON and XML parsing. They are stored in the gb_relay/ResponseType directory. You can create your own parser. Make sure to keep the file name and the class name the same, and add a parseToArray($value) function.

Success Conditions

There are two PHP array variables that will get created: $response, and $http_code. Use them to mark the Request as successful or not. You can also modify the ResponseType parsers for more sophisticated determination.

Modifier

Specify how EE should modify its data upon being triggered. Currently only supports Channel Entry and Member modifications

Title (required)

What to modify

Select the channel or member role

Conditions

Specify the entry or member properties to filter the item you want to modify. E.g. set $entry, =, and <?php return $values['entry_id']; ?> if you want to target the channel entry that triggered this Modifier action.

Properties that will get saved to the qualifying items(s)

Specify the new field values.

Trigger

Acts as an 'event listener' for triggering Request or Modifier actions.

Description (optional)

Execute on

This add-on supports all extension hooks. Go to Adding extensions section to learn more.

Specify the matching conditions

Set up conditions to check for the values of PHP ${variables} to fire this trigger action or not. If you are triggering off a Request action, you have access to $response. Also, since the Request is likely triggered by an extension hook, you have access to the variables in the extension definition (setValues()) e.g. the trigger that follows a request that was triggered by after_channel_entry_save has access to the $entry object and the $values array. The variables will keep getting passed down in the chain.

Actions

Select the Request or Modifier actions that you want to trigger.

Auto run?

Turning this on will make the events created by this trigger fire automatically upon being triggered. All events can be viewed on the Events page.

Enabled

Adding extensions

Create actions for any EE extensions (native and 3rd-party) by creating an action file in the CustomExtension/ directory. For example, to integrate GB Relay with freeform_next_form_after_submit, create a file named CustomExtension/FreeformNextFormAfterSubmit.php. Below is an outline of a basic extension file:

<?php

use GB\Relay\Core\BaseExtension;

if (!defined('BASEPATH')) exit('No direct script access allowed');

class FreeformNextFormAfterSubmit extends BaseExtension
{
    public function setValues($form, $submission)
    {
        $eeTemplateData = [
            'this:submission_id' => $submission->id,
        ];
        $this->setPostData(['eeTemplateData' => $eeTemplateData, 'form' => $form, 'submission' => $submission]);
    }
}
setValues() (required)

Copy the parameters supplied by the extension hooks to the setValues() method, then use $this->setPostData() to specify what variables you want to pass down the chain for the subsequent action usage. This gives you a chance to rename the variable(s) to avoid duplicate variable names if you have a complex/layered setup. eeTemplateData is reserved for any variables that you'd like to use in your EE template. In our example above, you can use {this:submission_id} to display the submission ID.

priority (optional)
settings (optional)
enabled (optional)
Check if new

To determine if the data object is new e.g. ChannelEntry or Member, it is possible to configure an extension to check the value of a field or status. In the default CustomExtension files, the AfterChannelEntrySave.php utilizes the before_channel_entry_save extension hook to determine if the entry is new by checking the $entry->entry_id value.

checkNewExtension

Designate the specific extension hook for the checkNew() method execution.

checkNew() (required if checkNewExtension is specified)

Similar to the setValues() method, copy the parameters supplied by the extension hook you specified in checkNewExtension. However, this assessment does not affect the variables passed in the action chain, except for the creation of the $new variable. Return true or false based on the condition, and the $new variable will influence subsequent actions.

yesForNewOnly (optional)

Text translation for condition when you only want to trigger the action on new. Default to Only on new

noForNewOnly (optional)

Text translation for condition when you want to trigger the action on every extension execution. Default to On every save

After the extension file is created, go to GB Relay > Resync Extensions to add it to EE. Contact [email protected] if you need help with creating the extensions.

Changelog

1.0.0

Support

Email Gilbert at [email protected]

Support continuous development for this add-on

There will be a 30% fee of the original price per year to continue getting the most up-to-date version of this add-on.

License

Permitted Use

One license grants the right to perform one installation of the software. Each additional installation of the software requires an additional purchased license. For free software, no purchase is necessary, but this license still applies.

Restrictions

Unless you have been granted prior, written consent from Gilbert Lin, you may not:

Display of Copyright Notices

All copyright and proprietary notices and logos in the control panel and within the software files must remain intact.

Software Modification

You may alter, modify, or extend the software for your own use, or commission a third-party to perform modifications for you, but you may not resell, redistribute, or transfer the modified or derivative version without prior written consent from Gilbert Lin. The modifications by you or the commissioned third-party may not infringe and/or violate Gilbert Lin's license rights. Components from the software may not be extracted and used in other programs without prior written consent from Gilbert Lin.

Disclaimer of Warranty

The software is provided "as is", without warranty of any kind, expressed or implied, including, but not limited to, warranties of quality, performance, non-infringement, merchantability, or fitness for a particular purpose. Further, Gilbert Lin does not warrant that the software or any related service will always be available.

Limitations of Liability

You assume all risk associated with the installation and use of the software. In no event shall the authors or copyright holders of the software be liable for claims, damages, or other liability arising from, out of, or in connection with the software. License holders are solely responsible for determining the appropriateness of use and assume all risks associated with its use, including but not limited to the risks of program errors, damage to equipment, loss of data or software programs, or unavailability or interruption of operations.