Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1122832
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 5 months ago.
Improve this questionI want to integrate custom logic after submit form.
I want to store contact form data in the custom table, if data is stored then the response would be true otherwise false.
I am using wpcf7_before_send_mail hook
Please help me how can I do this.
My sample code here
function save_data_to_project_after_form_submit( $contact_form ) {
// Save data to my custom table
if(data save to database){
// Same as currently working and mail send
} else {
// giving error message something went wrong and mail should be not send.
}
} add_action( 'wpcf7_before_send_mail', 'save_data_to_project_after_form_submit', 10, 1 );
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 5 months ago.
Improve this questionI want to integrate custom logic after submit form.
I want to store contact form data in the custom table, if data is stored then the response would be true otherwise false.
I am using wpcf7_before_send_mail hook
Please help me how can I do this.
My sample code here
function save_data_to_project_after_form_submit( $contact_form ) {
// Save data to my custom table
if(data save to database){
// Same as currently working and mail send
} else {
// giving error message something went wrong and mail should be not send.
}
} add_action( 'wpcf7_before_send_mail', 'save_data_to_project_after_form_submit', 10, 1 );
Share Improve this question edited Jun 14, 2018 at 7:37 vishal patel asked Jun 13, 2018 at 9:55 vishal patelvishal patel 1012 bronze badges 3- 1 I am not sure to understand, on which condition you don't want to store data ? to store all forms, you can use that contactform7.com/save-submitted-messages-with-flamingo – mmm Commented Jun 13, 2018 at 9:58
- Try to ALWAYS include your code. How can we help you if we can't see what you have tried? Also, if you only want to store the data, use Flamingo like @mmm commented. – Bjorn Commented Jun 13, 2018 at 11:36
- I have updated my code. – vishal patel Commented Jun 14, 2018 at 7:37
1 Answer
Reset to default 1Little late to the party (5 years...) but for future generations stumbling upon this question, you can use &$abort
in wpcf7_before_send_mail
hook to prevent mail from sending:
add_action('wpcf7_before_send_mail','your_function',10,3);
function collect_email($wpcf7_data, &$abort, $object){ //pass reference
/* your code here */
if($data_saved == true){
$object->set_response("Data saved");
}
else {
$abort = true;
$object->set_response("Data not saved");
}
}
If you want to have even more control over ajax response, you can use feedback filter:
add_filter('wpcf7_feedback_response', function( $response){
/* do your stuff with $response array */
return $response;
});
本文标签: customizationContact form 7 ajax response truefalse based on some condtion
版权声明:本文标题:customization - Contact form 7 ajax response truefalse based on some condtion 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299259a1930410.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论