• Hi,

    We are using FS Contact 4.0.39.

    I have a form where I have added a hidden field: page_address. I want to use PHP code to fill in the value for that hidden field. I found this page: http://www.fastsecurecontactform.com/shortcode-options which shows how to do this. But it isn’t working for me.

    I have added this code to the template file:

    <?php if ( isset($si_contact_form) )  {
    	echo $si_contact_form->si_contact_form_short_code( array(
    		'form' => '2',
     		'page_address' => "$location_string",
    	) );
    } ?>

    But nothing show up, no form at all. If I add this code:

    echo do_shortcode("[si-contact-form form='2' hidden='page_address=".$location_string . "']");

    The form displays but the hidden field that I added called page_address has a value of “”. But there is another hidden field called page_address after the submit button that has the value set to the address in $location_string. I need to be able to pass the page_address field to MailChimp, so I need the hidden field I setup to have the address in it. I then tried this code:

    echo do_shortcode("[si-contact-form form='2' page_address='".$location_string . "']");

    But my hidden page_address field is still “” and no page_address hidden field after the submit.

    The check for $si_contact_form being set must be failing in the template, so do I need to set it somehow in the template to use the PHP code from the Tip? How do I get my page_address hidden field to have the address in it?

    Thank you.

    https://wordpress.org/plugins/si-contact-form/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi for the code above if it is not working for you please get in contact with the developer. Mike Challis will investigate further your issue as per his instructions in the URL you mentioned above.

    Although his code was referring to the following.

    <?php
    if ( isset($si_contact_form) )  {
     echo $si_contact_form->si_contact_form_short_code( array(
     'form' => '1',
     'email_to' => "$name,$email_to",
      ) );
    }
    ?>

    In your usage of the above code you changed the following ’email_to’ => “$name,$email_to”, to ‘page_address’ => “$location_string”,.

    I think this is where you are making an error with your syntax but I am not a developer, Mike Challis will be able to help you further.

    Thread Starter ljkeashly

    (@ljkeashly)

    Hi again,

    I also noticed that we are getting the following:
    <b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/xxx/public_html/wp-content/plugins/si-contact-form/includes/class-fscf-process.php</b> on line <b>478</b>

    I don’t know if that is from the above or enabling Silent Remote Sending for MailChimp integration.

    But we need to get rid of that Warning message on pages.

    Thanks

    Hi, do you have debug enabled in wp-config.php file?

    Thread Starter ljkeashly

    (@ljkeashly)

    Hi,

    Mike’s website says to use this forum for non-paid support questions, his contact page is only for non-support questions and his Help Desk is for paid support.

    Yes, I turned debug on, but it didn’t show anything.

    I want to set the field page_address to a php variable, which is why I changed ’email_to’ to ‘page_address’, which is my hidden field that I want to have the address put in.

    Any other ideas?

    Thanks.

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

The topic ‘Adding PHP to hidden field’ is closed to new replies.