WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Scott Kingsley Clark
    Member
    Posted 6 months 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);

    http://wordpress.org/plugins/gravity-forms-salesforce/

  2. Scott Kingsley Clark
    Member
    Posted 6 months 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
    Member
    Plugin Author

    Posted 6 months 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.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.