• Resolved kaysg

    (@kaysg)


    I am trying to include the date as the hidden value submitted to salesforce. I found the topic pass-query-param-to-field-value at: https://wordpress.org/support/topic/pass-query-param-to-field-value

    but i am having a difficult time following along/ making it work for me use.

    Could you point me in the right direction? thanks Graham

    The filter code i am using from within a custom plugin is:
    ‘add_filter( ‘salesforce_w2l_field_value’, ‘salesforce_w2l_field_value_querystring_example’, 10, 3 );

    function salesforce_w2l_field_value_querystring_example( $val, $field, $form ){

    $form_id = “3”; // form id to act upon
    $field_name = ’00Nj0000008tKm1′; // API Name of the field your want to autofill
    $qs_var = date(‘m/d/Y’); // e.g. ?source=foo

    if( $form == $form_id && $field_name == $field ){
    if( isset( $_GET[ $qs_var ] ) ){
    return $_GET[ $qs_var ];
    }
    }

    return $val;

    }’

    and i am attempting to apply it to the following input field:
    ‘<input type=”hidden” id=”sf_00Nj0000008tKm1″ class=”w2linput hidden” name=”00Nj0000008tKm1″ value=”test1″>’

    https://wordpress.org/plugins/salesforce-wordpress-to-lead/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Nick Ciske

    (@nickciske)

    Close, but your code is still looking at the querystring… try this:

    add_filter( 'salesforce_w2l_field_value', 'salesforce_w2l_field_value_date_example', 10, 3 );
    
    function salesforce_w2l_field_value_date_example( $val, $field, $form ){
    
    $form_id = "3"; // form id to act upon
    $field_name = '00Nj0000008tKm1'; // API Name of the field your want to autofill
    
    if( $form == $form_id && $field_name == $field ){
    return date('m/d/Y');
    }
    }
    
    return $val;
    
    }
    Thread Starter kaysg

    (@kaysg)

    Thanks except for one extra closing bracket it works great thanks for the help- corrected below

    add_filter( 'salesforce_w2l_field_value', 'salesforce_w2l_field_value_date_example', 10, 3 );
    
    function salesforce_w2l_field_value_date_example( $val, $field, $form ){
    
    $form_id = "3"; // form id to act upon
    $field_name = '00Nj0000008tKm1'; // API Name of the field your want to autofill
    
    if( $form == $form_id && $field_name == $field ){
    return date('m/d/Y');
    }
    
    return $val;
    
    }
    thefreshlab

    (@thefreshlab)

    Hi -adding to this thread, how can I include the current page into this – so that we know which page the enquiry came from.

    we have a number of house properties, with the enquiry form on each page – therefore when someone makes an enquiry about the property, we would like to include into the enquiry the property (page) name.

    many thanks

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

The topic ‘add dates to hidden fields values’ is closed to new replies.