Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1315287
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionMy goal is to save the data sent by the cf7 module inside a table external to those created by wordpress I found this procedure:
Create Custom table
CREATE TABLE candidate( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(50) );
Create contact form 7 fields
[text* title] [submit "Send"]
Add Below code to function.php
function contactform7_before_send_mail( $form_to_DB ) { //set your db details $mydb = new wpdb('root','','cistom_db','localhost'); $form_to_DB = WPCF7_Submission::get_instance(); if ( $form_to_DB ) $formData = $form_to_DB->get_posted_data(); $title = $formData['title']; $mydb->insert( 'candidate', array( 'title' =>$title ), array( '%s' ) ); } remove_all_filters ('wpcf7_before_send_mail'); add_action( 'wpcf7_before_send_mail', 'contactform7_before_send_mail' );
all clear and simple, however, I was wondering how to mix the specific id of the cf7 module?
$form_id = $contact_form->id();
if ($form_id == 2654 ) // 123 => Your Form ID.
{
}
Closed. This question is off-topic. It is not currently accepting answers.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionMy goal is to save the data sent by the cf7 module inside a table external to those created by wordpress I found this procedure:
Create Custom table
CREATE TABLE candidate( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(50) );
Create contact form 7 fields
[text* title] [submit "Send"]
Add Below code to function.php
function contactform7_before_send_mail( $form_to_DB ) { //set your db details $mydb = new wpdb('root','','cistom_db','localhost'); $form_to_DB = WPCF7_Submission::get_instance(); if ( $form_to_DB ) $formData = $form_to_DB->get_posted_data(); $title = $formData['title']; $mydb->insert( 'candidate', array( 'title' =>$title ), array( '%s' ) ); } remove_all_filters ('wpcf7_before_send_mail'); add_action( 'wpcf7_before_send_mail', 'contactform7_before_send_mail' );
all clear and simple, however, I was wondering how to mix the specific id of the cf7 module?
$form_id = $contact_form->id();
if ($form_id == 2654 ) // 123 => Your Form ID.
{
}
Share
Improve this question
edited Nov 26, 2020 at 14:49
Howdy_McGee♦
20.9k24 gold badges91 silver badges177 bronze badges
asked Nov 26, 2020 at 14:40
user14633289user14633289
11 bronze badge
3
- 1 I'm not sure what you mean by "mix" but this might be a better question asked on the Contact Form 7 forums so that it can be answered by people who are familiar with the plugin. – Howdy_McGee ♦ Commented Nov 26, 2020 at 14:50
- @Howdy_McGee pass only the id of the specific form to the code above which will have to save the data in a custom table – user14633289 Commented Nov 26, 2020 at 14:59
- Questions exclusively regarding 3rd party plugins is considered to be off-topic and better asked using their respective support methods. Please take the tour and visit our help center to learn more. A better place to ask this type of question may be The Official WordPress Forums or the plugin specific support. – Howdy_McGee ♦ Commented Nov 26, 2020 at 15:09
1 Answer
Reset to default 1Try this:
// Get current form.
$wpcf7 = WPCF7_ContactForm::get_current();
$contact_form_id = $wpcf7->id;
本文标签: plugin contact form 7Set id of cf7 in the data save function
版权声明:本文标题:plugin contact form 7 - Set id of cf7 in the data save function 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741962044a2407333.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论