Skip to content

Instantly share code, notes, and snippets.

@nciske

nciske/EmbedUrl.php

Last active Aug 29, 2015
Embed
What would you like to do?
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