Using Gravity Forms ‘gform_zohocrm_lead’ PHP filter

The gform_zohocrm_lead filter allows you to modify the lead arguments before they are sent to Zoho CRM.

Usage

To apply the filter 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.
  • $feed (Feed Object): The feed currently being processed.
  • $entry (Entry Object): The entry currently being processed.
  • $form (Form Object): The form currently being processed.

More information

See Gravity Forms Docs: gform_zohocrm_lead

Examples

Change Email Opt Out

This example changes 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;
}

Set Owner based on country

This example sets the lead owner based on the selected 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' ) {
        $country = rgar( $entry, '4' );
        $owners = array( 'Afghanistan' => 'The-Zoho-CRM-User-ID-Here', 'Albania' => 'The-Zoho-CRM-User-ID-Here' );
        $lead['SMOWNERID'] = rgar( $owners, $country );
    }
    return $lead;
}

Set the Layout

This example defines 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 );

Preserve Lead Source on Update

This example shows how to 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 );