These are functional examples that you can copy and paste directly into your project, in whole or in part.

Some examples are compatible with the free version of the plug-in and others require the commercial version. Each example includes a label indicating the version of the plug-in with which it is compatible.

CF7 Data Source - Practical Examples.

Get details of logged user

Free Version Professional Version

Reads the information of the logged user (login, email, first name, and last name) with the cf7-recordset field [cf7-recordset id="user-data" type="user" attributes="user_login,user_email,first_name,last_name" logged="1"]

<label> User login
[text* user-login] </label>

<label> User email
[email* user-email] </label>

<label> First name
[text first-name] </label>

<label> Last name
[text last-name] </label>

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

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

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

[cf7-link-field recordset="user-data" field="user-login" value="user_login"]
[cf7-link-field recordset="user-data" field="user-email" value="user_email"]
[cf7-link-field recordset="user-data" field="first-name" value="first_name"]
[cf7-link-field recordset="user-data" field="last-name" value="last_name"]

Users lists and their emails

Free Version Professional Version

Reads the users list (Ids, logins, and emails) with the cf7-recordset field [cf7-recordset id="users-data" type="user" attributes="ID,user_login,user_email"]

Fill in the email field with the email address of the selected user [cf7-link-field recordset="users-data" field="user-email" value="user_email" condition="record&#91;'ID'&#93; == {field.users-list}"]

<label> Users
[select users-list] </label>

<label> User email
[email* user-email] </label>

[cf7-recordset id="users-data" type="user" attributes="ID,user_login,user_email"]

[cf7-link-field recordset="users-data" field="users-list" value="ID" text="user_login"]
[cf7-link-field recordset="users-data" field="user-email" value="user_email" condition="record&#91;'ID'&#93; == {field.users-list}"]

List of published posts

Free Version Professional Version

Get the ids and titles of published posts [cf7-recordset id="posts-data" type="post" attributes="ID,post_title" condition="post_status='publish' AND post_type='post'"]

<label> Posts
[select posts-list] </label>

[cf7-recordset id="posts-data" type="post" attributes="ID,post_title" condition="post_status='publish' AND post_type='post'"]

[cf7-link-field recordset="posts-data" field="posts-list" value="ID" text="post_title"]

List of WooCommerce products

Professional Version

Get the ids and titles of published products [cf7-recordset id="products" type="post" attributes="ID,post_title" condition="post_status='publish' AND post_type='product'"] using the posts data source, and the price of the selected product from database [cf7-recordset id="price" type="database" engine="mysql" query="SELECT meta_value FROM {wpdb.postmeta} WHERE post_id={field.products-list} AND meta_key='_price'"]

<label> Products
[select products-list] </label>

<label> Price
[number product-price] </label>

[cf7-recordset id="products" type="post" attributes="ID,post_title" condition="post_status='publish' AND post_type='product'"]
[cf7-recordset id="price" type="database" engine="mysql" query="SELECT meta_value FROM {wpdb.postmeta} WHERE post_id={field.products-list} AND meta_key='_price'"]

[cf7-link-field recordset="products" field="products-list" value="ID" text="post_title"]
[cf7-link-field recordset="price" field="product-price" value="meta_value" text="post_title"]

Categories and its posts

Professional Version

Get the terms in the "Category" taxonomy using the taxonomy data source [cf7-recordset id="category-terms" type="taxonomy" taxonomy="category" attributes="term_id,name"] and the post list associated with the selected term, by using the database data source [cf7-recordset id="posts-list" type="database" engine="mysql" query="SELECT ID,post_title from {wpdb.posts} LEFT JOIN {wpdb.term_relationships} ON ({wpdb.posts}.ID = {wpdb.term_relationships}.object_id) WHERE {wpdb.term_relationships}.term_taxonomy_id = {field.categories}"]

<label> Categories
[select categories] </label>

<label> Posts
[select posts] </label>

[cf7-recordset id="category-terms" type="taxonomy" taxonomy="category" attributes="term_id,name"]
[cf7-recordset id="posts-list" type="database" engine="mysql" query="SELECT ID,post_title from {wpdb.posts} LEFT JOIN {wpdb.term_relationships} ON ({wpdb.posts}.ID = {wpdb.term_relationships}.object_id) WHERE {wpdb.term_relationships}.term_taxonomy_id = {field.categories}"]

[cf7-link-field recordset="category-terms" field="categories" value="term_id" text="name"]
[cf7-link-field recordset="posts-list" field="posts" value="ID" text="post_title"]

Country list and details

Professional Version

Uses the CSV data source to read a CSV file with the list of countries and their information [cf7-recordset id="country-data" type="csv" url="https://raw.githubusercontent.com/datasets/country-codes/master/data/country-codes.csv" headline="1" delimiter=","]

It fills the other fields in the form with the data of the country selected.

<label> Country list
[select country-list] </label>

<label> Region name
[text region-name] </label>

<label> Capital
[text capital] </label>

<label> Language
[text language] </label>

[cf7-recordset id="country-data" type="csv" url="https://raw.githubusercontent.com/datasets/country-codes/master/data/country-codes.csv" headline="1" delimiter=","]

[cf7-link-field recordset="country-data" field="country-list" value="official_name_en" text="official_name_en" condition="record&#91;'official_name_en'&#93;!=''"]

[cf7-link-field recordset="country-data" field="region-name" value="Region Name" condition="record&#91;'official_name_en'&#93;==&#34;{field.country-list}&#34;"]

[cf7-link-field recordset="country-data" field="capital" value="Capital" condition="record&#91;'official_name_en'&#93;==&#34;{field.country-list}&#34;"]

[cf7-link-field recordset="country-data" field="language" value="Languages" condition="record&#91;'official_name_en'&#93;==&#34;{field.country-list}&#34;"]

Get stock information from third-party services

Professional Version

Get the stock information from the external service https://www.alphavantage.co by using the JSON data source.

It fills the other fields in the form with the stock data.

<label>Stock Symbol
[text symbol "IBM"]</label>

<label>Open
[text open]</label>

<label>High
[text high]</label>

<label>High
[text low]</label>

<label>Price
[text price]</label>

[cf7-recordset id="stock-data" type="json" url="https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol={field.symbol}&apikey=12U67PHYF9R5QVIR"]

[cf7-link-field recordset="stock-data" field="open" value="02. open"]
[cf7-link-field recordset="stock-data" field="high" value="03. high"]
[cf7-link-field recordset="stock-data" field="low" value="04. low"]
[cf7-link-field recordset="stock-data" field="price" value="05. price"]