Contact Form 7 (CF7) provides many features to make your forms as simple or complex as you need. One of these important features is the ability to use Default Values in your form fields.
In this article, we will show you how to use default values from the post meta in your CF7 forms.
When to use default values in your forms
It’s useful to implement default values in form fields for a variety of cases:
- Help your user fill out a form faster.
- If your forms target registered users of the site.
- If the form needs to be called with a different default value depending on the referrer of the form.
- When you have a fixed value for a field but still need to display it to the user.
Getting default values from post meta
The simplest way of getting default values to your form is getting them from the post meta. There are no conditions to this and you simply set a default value for a form field. To do this, use the default keyword and set the desired default value.
[text* name default:post_meta "Michael Clarke"]
Example
The following form has default values for the Subject and Your Message fields. These default values are defined in post meta.
Form Code
Further reading
- Contact Form 7 – Getting Default Values from the Context
- Contact Form 7 – Setting Default Values to the Logged-In User
- Getting default values from HTTP requests in Contact Form 7
- Using multiple default values in Contact Form 7
- Getting default values from logged-in user in Contact Form 7
Have questions or need help?
If you are using the free version of CF7 Skins, you can get help via the CF7 Skins community and also the Contact Form 7 Support forum.
If you are using any of our Add-ons, we provide Premium Email Support to help with your questions and problems.