jpiper.kmi
Forum Replies Created
-
Forum: Plugins
In reply to: [Brilliant Web-to-Lead for Salesforce] Pass query param to field valueThanks for the suggestion. I believe I’ve got it working.
(see updated code below)add_filter( 'salesforce_w2l_field_value', 'salesforce_w2l_field_value_querystring_insert', 10, 3 ); function salesforce_w2l_field_value_querystring_insert( $val, $field, $form ){ // API Name of the field your want to autofill $field_name_source = 'SEO_Source__c'; $field_name_medium = 'SEO_Medium__c'; $field_name_campaign = 'SEO_Campaign__c'; $field_name_content = 'SEO_Content__c'; $field_name_term = 'SEO_Term__c'; $qs_var_source = 'utm_source'; // e.g. ?utm_source=google $qs_var_medium = 'utm_medium'; // e.g. ?utm_medium=ppc $qs_var_campaign = 'utm_campaign'; // e.g. ?utm_campaign=brand $qs_var_content = 'utm_content'; // e.g. ?utm_content=topCTA $qs_var_term = 'utm_term'; // e.g. ?utm_term=foo if( $field_name_source == $field ){ if( isset( $_GET[ $qs_var_source ] ) ){ return $_GET[ $qs_var_source ]; } else {}; } if( $field_name_medium == $field ){ if( isset( $_GET[ $qs_var_medium ] ) ){ return $_GET[ $qs_var_medium ]; } else {}; } if( $field_name_campaign == $field ){ if( isset( $_GET[ $qs_var_campaign ] ) ){ return $_GET[ $qs_var_campaign ]; } else {}; } if( $field_name_content == $field ){ if( isset( $_GET[ $qs_var_content ] ) ){ return $_GET[ $qs_var_content ]; } else {}; } if( $field_name_term == $field ){ if( isset( $_GET[ $qs_var_term ] ) ){ return $_GET[ $qs_var_term ]; } else {}; } if ($vals >= $val){return $vals;} else{return $val;}; }Forum: Plugins
In reply to: [Brilliant Web-to-Lead for Salesforce] Pass query param to field valueThanks for the quick reply! I’m certainly not to proud to admit I might have a bug. (See below for code.) I customized this in hopes to apply it to any form on the site, but only for the specific fields listed as variables.
add_filter( 'salesforce_w2l_field_value', 'salesforce_w2l_field_value_querystring_example', 10, 3 ); function salesforce_w2l_field_value_querystring_example( $val, $field, $form ){ // API Name of the field your want to autofill $field_name_source = 'SEO_Source__c'; $field_name_medium = 'SEO_Medium__c'; $field_name_campaign = 'SEO_Campaign__c'; $field_name_content = 'SEO_Content__c'; $field_name_term = 'SEO_Term__c'; $qs_var_source = 'utm_source'; // e.g. ?utm_source=google $qs_var_medium = 'utm_medium'; // e.g. ?utm_medium=ppc $qs_var_campaign = 'utm_campaign'; // e.g. ?utm_campaign=brand $qs_var_content = 'utm_content'; // e.g. ?utm_content=topCTA $qs_var_term = 'utm_term'; // e.g. ?utm_term=foo if( $field_name_source == $field ){ if( isset( $_GET[ $qs_var_source ] ) ){ return $_GET[ $qs_var_source ]; } else {}; } if( $field_name_medium == $field ){ if( isset( $_GET[ $qs_var_medium ] ) ){ return $_GET[ $qs_var_medium ]; } else {}; } if( $field_name_campaign == $field ){ if( isset( $_GET[ $qs_var_campaign ] ) ){ return $_GET[ $qs_var_campaign ]; } else {}; } if( $field_name_content == $field ){ if( isset( $_GET[ $qs_var_content ] ) ){ return $_GET[ $qs_var_content ]; } else {}; } if( $field_name_term == $field ){ if( isset( $_GET[ $qs_var_term ] ) ){ return $_GET[ $qs_var_term ]; } else {}; } return $vals; }Forum: Plugins
In reply to: [Brilliant Web-to-Lead for Salesforce] Pass query param to field valueI believe I found a bug in which this script seems to erase the values out of all the other hidden fields in the form. I’m trying to both set a hidden field value with the query-string and also hard code a different hidden field with a value in the basic form editor.
Any ideas?
Correction. The code above appears to work to input the value into a field called retURL, but it appears that it doesn’t have any impact on the URL the form is being directed to after submission.
I’m testing this out now, but still no luck. Are the opening/closing {} correct in this code? My text editor doesn’t seem to find the matches, so updated it to the following (still no luck though).
add_filter( 'salesforce_w2l_field_value', 'salesforce_w2l_field_urlredirect', 10, 3 ); function salesforce_w2l_field_urlredirect( $val, $field, $form ){ $postid = get_the_id(); // Target a specific field on all forms if( $field == 'retURL' ){ if( $field == 'retURL' && $postid == '671' ) $URL = 'http://www.mycompany.com/thank-you?option=1' ; else if( $field == 'retURL' && $postid == '669' ) $URL = 'http://www.mycompany.com/thank-you?option=2' ; else if ( $field == 'retURL' && $postid == '360' ) $URL = 'http://www.mycompany.com/thank-you?option=3' ; } if( $URL ){ $val = $URL; } return $val; }