Title: Add hidden fields to a form programatically
Last modified: January 2, 2021

---

# Add hidden fields to a form programatically

 *  Resolved [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * (@wpfan1000)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/add-a-hidden-field-programatically/)
 * Hi,
 * I need to have some hidden fields in a form in order to pass on info to the destination
   page once the form is submitted.
 * I need to set the value of each hidden field programmatically: the value of the
   field is based on a variable.
 * Eg:
 *     ```
       echo '<input type="hidden" name="bestprice" value="'.$bestprice.'">';
       ```
   
 * I found:
    [https://wpforms.com/wpforms-hidden-field/](https://wpforms.com/wpforms-hidden-field/)
 * But it does not seem to discuss how to set a hidden field programmatically, eg
   set the value based on a variable.
 * Is this possible?
 * If so, how?
 * Thanks ahead of time……
    -  This topic was modified 5 years, 5 months ago by [wpfan1000](https://wordpress.org/support/users/wpfan1000/).

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

 *  [Jade](https://wordpress.org/support/users/jadeam/)
 * (@jadeam)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/add-a-hidden-field-programatically/#post-13863431)
 * Hello [@wpfan1000](https://wordpress.org/support/users/wpfan1000/),
 * You might want to look into creating some custom Smart Tags that will pull the
   values that you want to set to the hidden fields the same way as mentioned in
   the guide that you cited.
 * Please check [this dev doc guide](https://wpforms.com/developers/how-to-create-a-custom-smart-tag/)
   on how you can create your custom Smart Tags.
 * I hope this helps.
 *  Thread Starter [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * (@wpfan1000)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/add-a-hidden-field-programatically/#post-13867663)
 * Ok, thanks

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

The topic ‘Add hidden fields to a form programatically’ is closed to new replies.

 * ![](https://ps.w.org/wpforms-lite/assets/icon.svg?rev=3254748)
 * [WPForms - Easy Form Builder for WordPress - Contact Forms, Payment Forms, Surveys, & More](https://wordpress.org/plugins/wpforms-lite/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpforms-lite/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpforms-lite/)
 * [Active Topics](https://wordpress.org/support/plugin/wpforms-lite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpforms-lite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpforms-lite/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [wpfan1000](https://wordpress.org/support/users/wpfan1000/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/add-a-hidden-field-programatically/#post-13867663)
 * Status: resolved