Contact Form 7 Data Source!

CF7 Data source plugin allows populating the "Contact Form 7" fields (text, email, URL, drop-down menu, ...) with data stored in external data sources, like a database, CSV file, URL parameters, users information, post data, server side code, taxonomies, Advanced Custom Fields (ACF), JSON objects.


CF7 Data source includes two new controls in the controls bar of Contact Form 7, recordset and recordset field link. The "recordset" control reads the information from the external data source (Like a database, a CSV file, a JSON object, Advanced Custom Fields (ACF), URL parameters, Serve Side code, or any other data source supported), and the "recordset field link" control for linking the recordsets and form fields to populate them with the recordset data.

A form can include several "recordset" fields, and it is possible to link multiple "recordset field link" controls to the same recordset.


Two quick use cases

Get the information of the registered user and populate the form fields for his name and email:

<label> Your name [text* your-name] </label>

<label> Your email [email* your-email] </label>

<label> Subject [text* your-subject] </label>

<label> Your message (optional) [textarea your-message] </label>

[cf7-recordset id="cf7-recordset-434" type="user" attributes="first_name, user_email" logged="1"]

[cf7-link-field recordset="cf7-recordset-434" field="your-name" value="first_name"]

[cf7-link-field recordset="cf7-recordset-434" field="your-email" value="user_email"]

[submit "Submit"]

Populates the list of WooCommerce products and get the price of the selected one:

<label>Products List [select menu-719]</label>

<label>Product Price [number number-534]</label>

[cf7-recordset id="cf7-recordset-619" type="database" engine="mysql" query="SELECT ID,post_title,meta_value as price FROM {wpdb.posts} posts, {wpdb.postmeta} meta WHERE posts.post_type='product' AND posts.ID=meta.post_id AND meta.meta_key='_regular_price'"]

[cf7-link-field recordset="cf7-recordset-619" field="menu-719" value="ID" text="post_title"]

[cf7-link-field recordset="cf7-recordset-619" field="number-534" value="price" condition="record['ID']=={field.menu-719}"]

[submit "Submit"]