Gravity Forms Salesforce Add-on
[resolved] Adding a new filter for GFSalesforceWebToLead push / send_request (3 posts)

  1. Scott Kingsley Clark
    Posted 2 years ago #

    I'd like to filter the data before it gets sent to Salesforce, for additional functionality for more complex setups and field mapping.

    You could add a $data filter before the 'send_request' method gets called in the 'push' method of GFSalesforceWebToLead, or a $args filter in the 'send_request' method before it gets sent to wp_remote_post. I'd be happy with either.

    Please also add a filter for the subdomain or domain itself that gets used in wp_remote_post.

    In: SFSalesforceWebToLead::push

    $data = array_map('stripslashes', $data);
    $data = apply_filters( 'gf_salesforce_push_data', $data, $form_meta, $entry );
    $result = self::send_request($data);

    In: SFSalesforceWebToLead::send_request

    // Set SSL verify to false because of server issues.
    $args = array(
    	'body'      => $post,
    	'headers'   => array(
    		'user-agent' => 'Gravity Forms Salesforce Add-on plugin - WordPress/'.$wp_version.'; '.get_bloginfo('url'),
    	'sslverify' => false,
    $args = apply_filters( 'gf_salesforce_request_args', $args, $debug );
    $sub = $debug ? 'test' : 'www';
    $sub = apply_filters( 'gf_salesforce_request_subdomain', $sub, $debug );
    $result = wp_remote_post('https://'.$sub.'.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8', $args);


  2. Scott Kingsley Clark
    Posted 2 years ago #

    I'd like to have the data filter added to GFSalesforce::create too, above the UTF-8 encoding:

    $merge_vars = apply_filters( 'gf_salesforce_create_data', $merge_vars, $form, $entry );
    // Make sure the charset is UTF-8 for Salesforce.
    $merge_vars = array_map(array('GFSalesforce', '_convert_to_utf_8'), $merge_vars);
  3. Zack Katz
    Plugin Contributor

    Posted 2 years ago #

    Thanks for your suggestions and code. This will be added later today.

    Please become a code contributor on Github - that way you can make pull requests and I can merge your changes more quickly.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Gravity Forms Salesforce Add-on
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.