Title: Adding PHP to hidden field
Last modified: August 31, 2016

---

# Adding PHP to hidden field

 *  [ljkeashly](https://wordpress.org/support/users/ljkeashly/)
 * (@ljkeashly)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/adding-php-to-hidden-field/)
 * 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](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/](https://wordpress.org/plugins/si-contact-form/)

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

 *  [mbrsolution](https://wordpress.org/support/users/mbrsolution/)
 * (@mbrsolution)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/adding-php-to-hidden-field/#post-6967810)
 * Hi for the code above if it is not working for you please get in [contact ](http://www.fastsecurecontactform.com/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](https://wordpress.org/support/users/ljkeashly/)
 * (@ljkeashly)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/adding-php-to-hidden-field/#post-6967838)
 * 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
 *  [mbrsolution](https://wordpress.org/support/users/mbrsolution/)
 * (@mbrsolution)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/adding-php-to-hidden-field/#post-6967843)
 * Hi, do you have debug enabled in wp-config.php file?
 *  Thread Starter [ljkeashly](https://wordpress.org/support/users/ljkeashly/)
 * (@ljkeashly)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/adding-php-to-hidden-field/#post-6967921)
 * 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.

 * ![](https://s.w.org/plugins/geopattern-icon/si-contact-form_dde2be.svg)
 * [Fast Secure Contact Form](https://wordpress.org/plugins/si-contact-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/si-contact-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/si-contact-form/)
 * [Active Topics](https://wordpress.org/support/plugin/si-contact-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/si-contact-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/si-contact-form/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [ljkeashly](https://wordpress.org/support/users/ljkeashly/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/adding-php-to-hidden-field/#post-6967921)
 * Status: not resolved