functions - Contact Form 7 - Delay auto responds

admin2025-01-08  3

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 2 months ago.

Improve this question

I'm looking for a way to delay the auto response (mail_2) from Contact Form 7 for 2 days. But I have no clue how to tackle it. I hope you have an idea.

I'm using the following code in functions.php

add_action( 'wpcf7_before_send_mail', 'send_custom_respond' );

function send_custom_respond($WPCF7_ContactForm) {

  $submission = WPCF7_Submission::get_instance();
  $posted_data = $submission->get_posted_data();
  $contact_name = $posted_data['your-name'];
  $contact_email = $posted_data['your-email'];

  $mail_2 = $WPCF7_ContactForm->prop('mail_2') ;
  $mail_2['subject'] = "Enjoying the trial?";
  $mail_2['body'] = "Hi ". $contact_name . ",\n how's the trial? Let us know if you need some assistance.";

  $WPCF7_ContactForm->set_properties(array("mail_2" => $mail_2));

  return $WPCF7_ContactForm;
}
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 2 months ago.

Improve this question

I'm looking for a way to delay the auto response (mail_2) from Contact Form 7 for 2 days. But I have no clue how to tackle it. I hope you have an idea.

I'm using the following code in functions.php

add_action( 'wpcf7_before_send_mail', 'send_custom_respond' );

function send_custom_respond($WPCF7_ContactForm) {

  $submission = WPCF7_Submission::get_instance();
  $posted_data = $submission->get_posted_data();
  $contact_name = $posted_data['your-name'];
  $contact_email = $posted_data['your-email'];

  $mail_2 = $WPCF7_ContactForm->prop('mail_2') ;
  $mail_2['subject'] = "Enjoying the trial?";
  $mail_2['body'] = "Hi ". $contact_name . ",\n how's the trial? Let us know if you need some assistance.";

  $WPCF7_ContactForm->set_properties(array("mail_2" => $mail_2));

  return $WPCF7_ContactForm;
}
Share Improve this question edited Apr 3, 2019 at 14:45 rudtek 6,3535 gold badges30 silver badges52 bronze badges asked Apr 3, 2019 at 14:11 FlintFlint 433 bronze badges 2
  • 2 Given that the submissions are not stored in the database, you won't be able to delay sending unless you save the submission somewhere. Have a look at Download Contact Form 7 Database Addon or Contact Form 7 Database as you may be able to create a cron script and plugin to scan this table and send an email for any submissions after 2 days. – Alexander Holsgrove Commented Apr 3, 2019 at 14:18
  • Have you found a solution to this issue maybe? – Marko.dev Commented May 23, 2022 at 13:58
Add a comment  | 

1 Answer 1

Reset to default 1

I needed this functionality a few weeks back, found a few of these threads which helped a bit but ultimately wasn't exactly what I needed, then found a few plugins already in the directory that did the trick.

This one seemed to do the trick, but there are others you can try: https://wordpress.org/plugins/delayed-notifications-for-contact-form-7/

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736268094a1247.html

最新回复(0)