From 4bbcc10dd3b63abfff80505dffd3c8323cd2142c Mon Sep 17 00:00:00 2001 From: Timi Wahalahti Date: Mon, 29 Apr 2024 15:49:48 +0300 Subject: [PATCH] Send copy of call for speakers email to the speaker itself (#1053) --------- Co-authored-by: ren <18050944+renintw@users.noreply.github.com> --- .../wordcamp-forms-to-drafts.php | 110 ++++++++++++++++-- 1 file changed, 102 insertions(+), 8 deletions(-) diff --git a/public_html/wp-content/plugins/wordcamp-forms-to-drafts/wordcamp-forms-to-drafts.php b/public_html/wp-content/plugins/wordcamp-forms-to-drafts/wordcamp-forms-to-drafts.php index 2074906be..fcbccd2b3 100644 --- a/public_html/wp-content/plugins/wordcamp-forms-to-drafts/wordcamp-forms-to-drafts.php +++ b/public_html/wp-content/plugins/wordcamp-forms-to-drafts/wordcamp-forms-to-drafts.php @@ -1,5 +1,4 @@ get_form_key_by_id( absint( $_POST['contact-form-id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing + + // Add speaker as a copy on the email. + if ( 'call-for-speakers' === $form_key ) { + $headers .= "Cc: {$reply_to_addr}\r\n"; + } + + return $headers; + } + + /** + * Modify the email subject for cases where more information is needed. + * + * We can use $_POST['contact-form-id'] without nonce verification as at this point Jetpack has already taken care if it. + * + * @param string $subject Feedback's subject line. + * @param array $all_values Feedback's data from old fields. + * + * @return string Email subject line. + */ + public function maybe_modify_email_subject( $subject, $all_values ) { + $form_key = $this->get_form_key_by_id( absint( $_POST['contact-form-id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing + // Add the site name and topic title on email subject. + if ( 'call-for-speakers' === $form_key ) { + $all_values = $this->get_unprefixed_grunion_form_values( $all_values ); + + /* translators: %1$s: site name; %2$s: topic title on submission; */ + $subject = sprintf( + __( 'Your %1$s Call for Speakers submission: %2$s', 'wordcamporg' ), + get_bloginfo( 'name' ), + sanitize_text_field( $all_values['Topic Title'] ) + ); + } + + return $subject; + } + + /** + * Modify the email message for cases where more information is needed. + * + * We can use $_POST['contact-form-id'] without nonce verification as at this point Jetpack has already taken care if it. + * + * @param string $message Feedback email message. + * @param array $message_array Feedback email message as an array. + * + * @return string Email message. + */ + public function maybe_modify_email_message( $message, $message_array ) { + $form_key = $this->get_form_key_by_id( absint( $_POST['contact-form-id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing + + // Modify the message to thank you and note about organizers getting back. + if ( 'call-for-speakers' === $form_key ) { + $wordcamp = get_wordcamp_post(); + + /* translators: %1$s: email address for organizing team; %2$s: original message; */ + $message = sprintf( + __( 'Hello,

Thank you for submitting on Call for Speakers! Here is an copy of your submission.

Please do not respond to this email, organizers will update you on the process. If you have any questions, send an email to organisers %1$s.
%2$s', 'wordcamporg' ), + $wordcamp->meta['E-mail Address'][0], + $message + ); + } + + return $message; + } + /** * Get speaker post based on WordPress.org user name *