Wordpress filters are built in at various places in the CampaignSuite code. These make it possible as a developer in the theme to influence the data that is currently used by CampaignSuite.
All filters are best placed in the functions.php of your theme. Click on the articles below to view the different filters.
This filter allows you to manipulate the contact and account array when this data is created just before a form is validated.
Use
add_filter( 'cs_validate_contact_account', 'custom_contact_account' );
//You can also use a Gravity Forms form ID to target a specific form
add_filter( 'cs_validate_contact_account_6', 'custom_contact_account' );
Parameters
$contact_account ( array ) This array passes the displayed contact and account arrays. This value must be returned in the filter function.
$payer ( object ) This is the full object of the CampaignSuite Payer class. This object contains various additional information about the payer.
This is the complete CampaignSuite\CampaignSuite\Render_response() class object. This object contains information about the response returned by the CS API.
Example
The example below writes a $_SESSION[‘orig_campaign’] value to the Salesforce Contact object.
$actions (array) This is an array of the available actions. You can add more elements to this array for custom actions.
Example
function get_feed_actions($actions)
{
$extraActions = [[
'label' => 'Maak een nieuwe Lead aan',
'value' => 'custom_lead',
'object' => 'Lead',
'objectName' => 'Lead'
]];
return array_merge($actions, $extraActions);
}
cs_get_contact_filter_fields
Description
With this filter, you can add more Salesforce contact fields to monitor when a contact ID is passed in the URL. By default, a contact is only found based on a contact ID. For more security it is possible to add more fields to this check.
The example below loops through Woocommerce items in a shopping cart and checks whether Destination IDs have been set. If so, these will be passed in the JSON call to the CampaignSuite API.
function custom_json()
{
global $woocommerce;
if ($woocommerce) {
$items = $woocommerce->cart->get_cart();
if ($items) {
$jsonItems = [];
foreach ($items as $values) {
$price = get_post_meta($values['product_id'], '_price',true);
$destination_id = get_post_meta($values['product_id'], '_sf_destination_id', true);
if ($destination_id) {
$jsonItems[] = [
'DestinationId' => $destination_id,
'Amount' => $price
];
}
}
if ($jsonItems) {
return [
'TransactionInfo' => [
'Gifts' => $jsonItems
]
];
}
}
}
return [];
}
With this action you can catch the webhook call yourself so that you can determine in your own action whether additional code needs to be executed as soon as a webhook call takes place from Salesforce/Findock
$payment (object) This object contains all information about the modified Payment object from the database table wp_gp_donations.
URL parameters
You can add various parameters in the URL of your website to activate debugging options of CampaignSuite. This makes it possible, for example, to debug the call to the CampaignSuite API or Converse and Findock.
Possible parameters are:
?cs_debug
https://www.website.nl/formulier?cs_debug=true
When this parameter is added, a form is automatically loaded without ajax. When the form is completed, you will see the JSON sent to the CampaignSuite API. It also shows you the JSON sent from the API to Salesforce. All this before Gravity Forms actually makes the input.
?cs_post=true
https://www.website.nl/formulier?cs_post=true
When this parameter is added, each page will show you the posted values. This can be useful if you want to know the exact field names posted. These names can be used in text area and HTML fields to prefill with those field values.
?cs_ajax
https://www.website.nl/formulier?cs_ajax=false
Use this parameter to overrule a Gravity Forms Ajax setting with true or false.
The ID passed in this parameter must be a Salesforce contact ID. If the contact is found in Salesforce, all assigned contact and account fields are pre-populated with the Salesforce values.
Client connections
As a developer you have the disposal to use the authorized connections in your own theme. There are a number of predefined functions that you can use per connection. Always start each connection in the following way first:
This function can be used to get a list of objects from SalesForce or a single one when an ID is passed.
/**
* @param string $objectType Name of the Salesforce object
* @param string $id Optional Salesforce ID of the object
* @param array $fields Optional array with fields to return from the object
* @param array $where Optional array with filters
*/
function getObjects($objectType = '', $id = '', $fields = [], $where = []){}
getObjectStructure
This function can be used to get the structure of a Salesforce object.
/**
* @param string $objectType The name of the Salesforce object
* @return object $response The API response
*
*/
function getObjectStructure($objectType = ''){}
createCampaignMember
This function makes a Post request to the API for a new CampaignMember object in Salesforce.
/**
* @param string $campaign_id Id of the Campaign
* @param string $contact_id Id of the Contact
* @return mixed
*/
function createCampaignMember($campaign_id, $contact_id){}
create
Function to create a new record of an object in Salesforce.
/**
* @param string $object Name of the Salesforce object
* @param array $data Data to save
*/
function create($object, $data){}
update
Function to update a record of an object in Salesforce.
/**
* @param string $object Name of the Salesforce object
* @param string $id Id of the Salesforce object
* @param array $data Data to save
*/
function update($object, $id, $data){}
delete
Function to delete a record from an object in Salesforce.
/**
* @param string $object Name of the Salesforce object
* @param string $id Id of the object to delete
*/
function delete($object, $id){}
Mautic
getForms
Function to retrieve all Mautic forms. When $id is passed, only one form is returned.
/**
* Function to retrieve all Mautic forms. When $id is passed, only one form is returned
*
* @param $id int Id of a Mautic form
* @return array $forms Returns an array of Mautic forms
*/
public function getForms($id = ''){}
createForm
This function will create a new Mautic form from a Gravity Forms form and its fields.
/**
* @param $type string Type can be Campaign or Standalone
* @param $form array The gravity Forms form as an array
*/
public function createForm($type, $form){}
postFormEntry
This function sends a wp_remote_post () request directly to Mautic. This is necessary because Mautic needs the visitor’s IP address to identify the contact.
/**
* @param $form_id int Id of the Mautic form
* @param $data array Array of the data to post to the form
*/
public function postFormEntry($form_id, $data){}
updateEntry
This feature updates a Mautic form submission based on certain conditions.
/**
* @param int $mautic_form_id The Mautic form ID
* @param array $where Array of conditions
* @param array $updates Array of fields to update
*/
function updateEntry($mautic_form_id, $where, $updates){}
Endpoints
When CampaignSuite is activated, a number of new endpoints will be added within Wordpress. These endpoints can be accessed by third party software. These endpoints are explained below with the associated parameters.
gp_webhook_path
This endpoint can be accessed by Findock and handles all webhook calls related to changes to a payment (or in the case of Findock 2 changes in the PaymentIntent). CampaignSuite automatically determines whether it is for Findock v1 or v2 based on the content of the call. With every API call to Findock, CampaignSuite automatically adds this URL as WebhookURL.
Example
One-click payment is a way to make a direct donation via a URL where the visitor is redirected to his / her bank page in one go. The advantage of this is that the complete flow is identical to filling in a donation form, but without going through the page containing the form.
In order for One-Click-Payment to work, you must at least meet the following points:
A form must be created which is fully linked to a Salesforce payment
The form must be on a page (hidden if necessary) in case the donor terminates his / her donation.
A thank you message or thank you page must be set up for successful donor capture.
The fields of the form you want to fill must be set to be filled dynamically. Read more information about this at this website .
If the above points are set, the URL for a One-Click-Payment can look like this:
There are a number of mandatory parameters in the URL:
amount
Enter the amount for the donation here
form_id
Enter the ID of the Gravity Forms form where the payment should be handled here
contact (optional)
Enter an ID of a Salesforce Contact
here
If you do not include a Salesforce Contact ID in the URL, a first name, last name, and email address are also required to include in the URL.
As soon as you click on the link, the form will be pre-filled with the required values and sent via the API. If fields are missing or errors occur, they will be displayed immediately.