Title: Programmatically set the &quot;To&quot; field
Last modified: August 31, 2016

---

# Programmatically set the "To" field

 *  [thefriendlancer](https://wordpress.org/support/users/thefriendlancer/)
 * (@thefriendlancer)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/programmatically-set-the-to-field/)
 * Hi Support.
    So we are currently building a web builder that automatically installs
   Contact Form 7 plugin. One of the requirements is be able to set the user’s email
   address as the the default “To” value. I was able to locate that the info in 
   the Contact Form’s “Mail” settings is stored in the wp_postmeta table. A snippet
   of the data saved in wp_postmeta is as follows:
 * > [your-message]”;s:9:”recipient”;s:{SOME NUMBER}:”{EMAIL ADDRESS HERE}”;s:18:”
   > additional_headers”;s:22:”Reply-To: [your-email]”;s
 * I was able to successully set (via MySQL scripts) the value of {EMAIL ADDRESS
   HERE} above.
    But the {SOME NUMBER} data seems to be set by a certain value. 
   I can’t figure out how it can be done or how should the number be generated.
 * Please help and thanks in advance.
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

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

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/programmatically-set-the-to-field/#post-7097574)
 * It is the length of characters
 * r e c i p i e n t => 9
    a d d i t i o n a l _ h e a d e r s => 18
 * Don’t edit serialized text in DB directly. You are breaking the structure.
 * If you want to change the default value in the To field, you can use wpcf7_default_template
   filter.
 *  Thread Starter [thefriendlancer](https://wordpress.org/support/users/thefriendlancer/)
 * (@thefriendlancer)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/programmatically-set-the-to-field/#post-7097638)
 * Thanks Takayuki-san for the quick response!
    Yeah – I figure out I am doing something
   wrong updating the data on the DB directly.
 * Can you please give me samples on how wpcf7_default_template is used?
 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/programmatically-set-the-to-field/#post-7097640)
 * Maybe this will help: [https://wordpress.org/support/topic/custom-default-form-template](https://wordpress.org/support/topic/custom-default-form-template)

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

The topic ‘Programmatically set the "To" field’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [To field](https://wordpress.org/support/topic-tag/to-field/)

 * 3 replies
 * 2 participants
 * Last reply from: [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/programmatically-set-the-to-field/#post-7097640)
 * Status: not resolved