Skip to content

Commit

Permalink
Alter application emails to include link to WC Central (#1416)
Browse files Browse the repository at this point in the history
* Adjust messaging for application emails
  • Loading branch information
pkevan authored Oct 29, 2024
1 parent 3052e3b commit 2bbc491
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,15 @@ public function submit_application( $post_data ) {
$message = $application_data->get_error_message();
$notice_classes = 'notice-error';
} else {
$this->create_post( $application_data );
$application_post = $this->create_post( $application_data );
if ( is_wp_error( $application_post ) ) {
// Set application post to an int, rather than wp_error.
$application_post = 0;
}
$this->notify_applicant_application_received(
$this->get_organizer_email(),
$this->get_event_location()
$this->get_event_location(),
$application_post
);

$this->notify_new_application_in_slack();
Expand Down Expand Up @@ -253,8 +258,9 @@ public function display_notice( $message, $notice_classes ) {
*
* @param string $email_address
* @param string $event_city
* @param int $application_post id of post created on WC Central.
*/
public function notify_applicant_application_received( $email_address, $event_city ) {
public function notify_applicant_application_received( $email_address, $event_city, $application_post = 0 ) {
//translators: Name of the event. E.g. WordCamp or meetup.
$subject = sprintf( __( "We've received your %s application", 'wordcamporg' ), $this->get_event_label() );
$headers = array(
Expand All @@ -265,12 +271,26 @@ public function notify_applicant_application_received( $email_address, $event_ci
//translators: 1: Name of the event. 2: City of the event.
$message = sprintf(
__(
"Thank you for applying to organize a %1\$s in %2\$s! We'll send you a follow-up e-mail once we've had a chance to review your application.",
"Thank you for applying to organize a %1\$s in %2\$s! We'll send you a follow-up e-mail once we've had a chance to review your application.\n\n",
'wordcamporg'
),
$this->get_event_label(),
sanitize_text_field( $event_city )
);
$message .= sprintf(
"---- Internal details for the Community Team ----\n
Name: %1\$s\n
Type: %2\$s",
$this->get_event_label(),
sanitize_text_field( $event_city ),
);

if ( 0 !== $application_post ) {
$message .= sprintf(
"\nURL: https://central.wordcamp.org/wp-admin/post.php?post=%1\$d&action=edit",
absint( $application_post )
);
}

wp_mail( $email_address, $subject, $message, $headers );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function get_default_application_values() {
*
* @param array $data
*
* @return bool|WP_Error
* @return int|WP_Error
*/
public function create_post( $data ) {
// Create the post.
Expand Down Expand Up @@ -201,7 +201,7 @@ public function create_post( $data ) {

$this->post = get_post( $post_id );

return true;
return $post_id;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function get_default_application_values() {
*
* @param array $data
*
* @return bool|WP_Error
* @return int|WP_Error
*/
public function create_post( $data ) {
// Create the post.
Expand Down Expand Up @@ -264,7 +264,7 @@ public function create_post( $data ) {

$this->post = get_post( $post_id );

return true;
return $post_id;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static function get_application_report_url() {
*
* @param array $data
*
* @return bool|\WP_Error
* @return int|\WP_Error
*/
public function create_post( $data ) {
// Create the post.
Expand Down Expand Up @@ -259,7 +259,7 @@ public function create_post( $data ) {
);

$this->post = get_post( $post_id );
return true;
return $post_id;
}

/**
Expand Down

0 comments on commit 2bbc491

Please sign in to comment.