Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter whuggett

    (@whuggett)

    Specifically, this is what I added to the Functions.php file.

    /*----------------------------------------------------------------------*/
    /* Custom function for IP Address Tracking in Contact Form
    /*----------------------------------------------------------------------*/
    
    // Save user ip in a specific field
    // -- replace IP_Address__c with your custom field name
    // -- make a hidden text field in your lead form (make sure it's enabled)
    // -- make sure it can store up to 45 characters (for IPv6 addresses)
    
    add_filter( 'salesforce_w2l_field_value', 'salesforce_w2l_ip_field', 10, 3 );
    
    function salesforce_w2l_ip_field( $val, $field, $form ){
    
    	$my_ip_field = 'IP_Address__c';
    
    	// Target a specific field on all forms
    	if( $field == my_ip_field ){
    
    		if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    		    $ip = $_SERVER['HTTP_CLIENT_IP'];
    		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    		    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    		} else {
    		    $ip = $_SERVER['REMOTE_ADDR'];
    		}
    
            $val = $ip;
    
    	}
    
        return $val;
    
    }
    Thread Starter whuggett

    (@whuggett)

    Here’s a link to our contact form…
    Contact Form

    I copied and pasted the code from the sf_w2l_user_ip.php file and changed the custom ip field name to “IP_Address__c”, as it is in SalesForce and on our contact form’s hidden field.

    Thanks.

    Thread Starter whuggett

    (@whuggett)

    Do I need to identify the form number in the add_filter? I’m using multiple forms, and can’t seem to get it to work yet on the main contact form (#1).

    Thread Starter whuggett

    (@whuggett)

    Thanks Nick. I assume this goes in the functions.php of the theme, as per the Readme.txt instructions?

    Thread Starter whuggett

    (@whuggett)

    Ah yes. Awesome, works!

    Thread Starter whuggett

    (@whuggett)

    When I look at the published code it looks like a class is set for “.salesforce_w2l_lead_1”. I assume this is the styling for Form ID 1?

    In the CSS can I create others like “.salesforce_w2l_lead_#” depending on the Form ID # I want to style?

    I tried adding the _1 to the existing “.salesforce_w2l_lead” in my customs.css file just to distinguish what I’ve already setup for Form ID 1, but it doesn’t seem to recognize that.

    How do I properly assign a class based on the Form ID?

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)