Skip to content

Instantly share code, notes, and snippets.

@nciske
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nciske/10047552 to your computer and use it in GitHub Desktop.
Save nciske/10047552 to your computer and use it in GitHub Desktop.
Add embed URL to SalesForce WordPress to Lead
<?php
/*
How to use:
1. Create a custom URL field at SalesForce
2. Replace URL_CUSTOM_FIELD_NAME below with the name of the custom field you setup in SalesForce,
it will be something like EmbedUrl__c
3. Add a hidden field to each form with the same field name (e.g. "EmbedUrl__c").
4. Make sure the hidden field is enabled (or it won’t be output with the form/get filled/be sent to SF).
5. Profit
*/
add_filter( 'salesforce_w2l_field_value', 'salesforce_w2l_field_embedurl', 10, 3 );
function salesforce_w2l_field_embedurl( $val, $field, $form ){
// Target a specific field on all forms
if( $field == 'URL_CUSTOM_FIELD_NAME' )
$val = esc_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
return $val;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment