How to get form data in Contact Form 7
Contact form 7 is a wordpress plugin used to add form in a wordpress website without adding any custom code. Contact form 7 allow us an area in admin panel where we can create as many forms that we want and we can add several fields on a simple click one by one. We can also manage email message, which notify admin or user. We can add multiple email addresses as recover. We can also include file upload option with contact form 7. Most of the websites which are built in wordpress prefer contact form 7.
First we have to check the form is working fine and sent an email to defined email in admin panel. We will use `wpcf7_before_send_mail` hook which is perform automatically when a contact form 7 form submitted successfully. `wpcf7_before_send_mail` will fire before email will sent to the admin. Use below code in functions.php to get form data.
add_action( 'wpcf7_mail_sent', 'custom_wpcf7_mail_sent_function' );
function custom_wpcf7_mail_sent_function( $contact_form ) {
$title = $contact_form->title; //get contact form name
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
}
}
Contact form 7 is a wordpress plugin used to add form in a wordpress website without adding any custom code. Contact form 7 allow us an area in admin panel where we can create as many forms that we want and we can add several fields on a simple click one by one. We can also manage email message, which notify admin or user. We can add multiple email addresses as recover. We can also include file upload option with contact form 7. Most of the websites which are built in wordpress prefer contact form 7.
First we have to check the form is working fine and sent an email to defined email in admin panel. We will use `wpcf7_before_send_mail` hook which is perform automatically when a contact form 7 form submitted successfully. `wpcf7_before_send_mail` will fire before email will sent to the admin. Use below code in functions.php to get form data.
add_action( 'wpcf7_mail_sent', 'custom_wpcf7_mail_sent_function' );
function custom_wpcf7_mail_sent_function( $contact_form ) {
$title = $contact_form->title; //get contact form name
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
}
}
How to install contact form 7
- Login wordpress admin panel and click on Add New under Plugins.
- You will see a input search field, enter `Contact Form 7` and hit enter &
- After that click on Install now button. When plugin will installed successfully, click on `Activate` to activate the plugin.
Recommanded Articles
- Generate Dummy Posts in WordPress
- How to add captcha in Contact Form 7
- how to create a cron job in wordpress
- How to get form data in Contact Form 7
- Insert Update Delete Select query in WordPress
- How to increase website speed
- Create plugin in WordPress in which create table in DB on activate
- Create new tab under my account WooCommerce frontend
- Custom image sizes in WordPress
- Get posts by meta key and meta value in WordPress
Latest Comments
Russel
21 Dec 2020Rinku Thakur
22 Dec 2020Carlos vergus
27 Dec 2020Gary
31 Dec 2020Barber https://netflix.com/
15 Oct 2021