DescriptionUsageParametersExamples1. Change Email Opt Out2. Set Owner based on country3. Set the Layout4. Preserve Lead Source on UpdatePlacementSource Code
Description
This filter can be used to modify the lead arguments before they are sent to Zoho CRM.
Usage
The following would apply to all feeds:
add_filter( 'gform_zohocrm_lead', 'your_function_name', 10, 4 );
To target feeds for a specific form append the form id to the hook name. (format: gform_zohocrm_lead_FORMID)
add_filter( 'gform_zohocrm_lead_4', 'your_function_name', 10, 4 );
Parameters
$lead array
The lead arguments are an associative array.
array(
'Email Opt Out' => 'false',
'Description' => 'some text',
'Lead Source' => 'Advertisement',
'Lead Status' => 'Not Contacted',
'Rating' => 'Acquired',
'SMOWNERID' => 'The-Zoho-CRM-User-ID-Here',
'options' => array(
'duplicateCheck' => '1',
'isApproval' => 'false',
'wfTrigger' => 'false'
),
)
$feed Feed Object
The feed currently being processed.
$entry Entry Object
The entry currently being processed.
$form Form Object
The form currently being processed.
Examples
1. Change Email Opt Out
This example shows how you can change the 『Email Opt Out』 setting based on a field value in the Entry Object.
add_filter( 'gform_zohocrm_lead_4', 'change_lead_argument', 10, 4 );
function change_lead_argument( $lead, $feed, $entry, $form ) {
if ( rgars( $feed, 'meta/feedName') == 'Zoho CRM Feed 2' && rgar( $entry, '5' ) == 'No' ) {
$lead['Email Opt Out'] = 'true';
}
return $lead;
}
2. Set Owner based on country
add_filter( 'gform_zohocrm_lead_9', 'change_lead_argument', 10, 4 );
function change_lead_argument( $lead, $feed, $entry, $form ) {
if ( rgars( $feed, 'meta/feedName' ) == 'Zoho Sales Inquiry' ) {
// get the selected country from field 4
$country = rgar( $entry, '4' );
// define an array containing the countries and the zoho crm id to be used for that country
$owners = array(
'Afghanistan' => 'The-Zoho-CRM-User-ID-Here',
'Albania' => 'The-Zoho-CRM-User-ID-Here',
);
// replace the feed configured owner with the id by using the $country as the key to the value in the $owners array
$lead['SMOWNERID'] = rgar( $owners, $country );
}
return $lead;
}
3. Set the Layout
This example shows how you can define the Layout the lead should use for a specific feed of form 4.
add_filter( 'gform_zohocrm_lead_4', function( $lead, $feed, $entry, $form ) {
if ( rgars( $feed, 'meta/feedName') == 'Zoho CRM Feed 2' ) {
$lead['Layout'] = array( 'name' => 'the layout name here', 'id' => 'the layout id here' );
}
return $lead;
}, 10, 4 );
4. Preserve Lead Source on Update
This example shows how you can preserve any existing Lead Source in Zoho for all feeds on form 33.
add_filter( 'gform_zohocrm_lead_33', function( $lead, $feed, $entry, $form ) {
unset( $lead['Lead_Source'] );
return $lead;
}, 10, 4 );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
gf_apply_filters( 'gform_zohocrm_lead', $form['id'], $lead, $feed, $entry, $form )
This filter is located in GFZohoCRM::create_lead() in class-gf-zohocrm.php.