bookmark_bordergform_zohocrm_lead

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

    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;
}

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