Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email notifications #232

Merged
merged 24 commits into from
May 7, 2024
Merged

Email notifications #232

merged 24 commits into from
May 7, 2024

Conversation

amieiro
Copy link
Collaborator

@amieiro amieiro commented Apr 23, 2024

This PR adds email notifications to all the attendees of an event around 1 hour and 1 day before the event.

To test this PR, I recommend you this configuration:

  • WP Crontrol plugin to view the scheduled jobs.
  • Mailtrap or some similar tool to be able to easily review the emails sent by this PR.
  • WP Mail SMTP or another SMTP plugin to easily configure the email sending to Mailtrap.

To test this PR, you can:

Create an event. In this example, I created an event for the May month. As I am locally work in CEST timezone (UTC+2) and the form is using UTC, I need to start on 2024-04-30 22:00 (2024-05-01 00:00 UTC time) and finish on 2024-05-31 21:59 (2024-05-31 23:59 UTC time).

image

Once I published the event, with the WP Crontrol plugin I can see the custom cron events (in CEST timezone):

  • One 1 hour before the event: 2024-04-30 23:00 CEST.
  • One 23 hours before the event: 2024-04-30 00:00 CEST.

You can see in the notifications:

  • The post_id (event_id) as parameter.
  • The Wporg\TranslationEvents\Notifications\Notifications_Send->send_notifications() as the action that will be executed when this event will be fired.

image

Each time I modified the event, all these custom cron events are deleted and re-scheduled, to use the new start time.

To fire one of these events manually, you can use the Run now link, available in each custom cron event.

image

Once the custom cron event is fired, you will receive an email like this:

image

Fixes #168.

@amieiro amieiro marked this pull request as ready for review April 29, 2024 14:49
Copy link
Member

@akirk akirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some ideas to improve the e-mail text.

includes/notifications/notifications-send.php Outdated Show resolved Hide resolved
includes/notifications/notifications-send.php Outdated Show resolved Hide resolved
includes/notifications/notifications-send.php Show resolved Hide resolved
includes/notifications/notifications-send.php Show resolved Hide resolved
includes/notifications/notifications-send.php Outdated Show resolved Hide resolved
includes/notifications/notifications-send.php Outdated Show resolved Hide resolved
Copy link
Member

@psrpinto psrpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work @amieiro! I really like the separation into Notifications_Schedule and Notifications_Send, makes things very easy to understand.

includes/attendee/attendee-repository.php Outdated Show resolved Hide resolved
includes/event/event-form-handler.php Outdated Show resolved Hide resolved
includes/notifications/notifications-send.php Outdated Show resolved Hide resolved
@amieiro amieiro requested review from psrpinto and akirk May 7, 2024 07:59
Copy link
Member

@akirk akirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, sorry for the false alarm of something not implemented. It looks good now! I thought we had said we'd wanted to show how many other people are also attending the event but we can do that in a follow-up PR. Good to get this one merged.

@amieiro amieiro merged commit 7a5229d into trunk May 7, 2024
3 checks passed
@amieiro amieiro deleted the email-notifications branch May 7, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notify people when an event they've RSVPed for starts
3 participants