Groups: notify members when events are published - #1829
Open
gedex wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an automatic “All Members” email trigger for GatherPress events when they are first published on Groups sites, reusing GatherPress’s existing email/recipient plumbing and preventing duplicate sends via a post-meta marker.
Changes:
- Loads a new notifications module from the
wporg-groups-frontendmu-plugin bootstrap. - Registers a
transition_post_statushook to schedule thegatherpress_send_emailscron action on first publish. - Persists a post-meta flag to avoid re-scheduling on subsequent edits/republishes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| public_html/wp-content/mu-plugins/wporg-groups-frontend/wporg-groups-frontend.php | Wires the new Notifications module into the plugin bootstrap (behind the existing GatherPress presence guard). |
| public_html/wp-content/mu-plugins/wporg-groups-frontend/inc/notifications.php | Implements the publish-transition hook and cron scheduling + meta marker for one-time member notifications. |
Comment on lines
+50
to
+58
| $scheduled = wp_schedule_single_event( | ||
| time(), | ||
| 'gatherpress_send_emails', | ||
| array( $post->ID, $recipients, '' ) | ||
| ); | ||
|
|
||
| if ( $scheduled ) { | ||
| update_post_meta( $post->ID, PUBLISH_NOTIFICATION_SCHEDULED_META, 1 ); | ||
| } |
Comment on lines
+33
to
+41
| function schedule_new_event_notification( string $new_status, string $old_status, \WP_Post $post ): void { | ||
| if ( | ||
| 'publish' !== $new_status || | ||
| 'publish' === $old_status || | ||
| 'gatherpress_event' !== $post->post_type || | ||
| get_post_meta( $post->ID, PUBLISH_NOTIFICATION_SCHEDULED_META, true ) | ||
| ) { | ||
| return; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1773.
Automatically schedules GatherPress's All Members email when an event is first published. A post-meta marker prevents duplicate notifications, while GatherPress continues to handle group-scoped recipients, opt-ins, email rendering, and asynchronous delivery.
Testing
Run
npm run build, then create and publish an event titled Auto-notify verification for https://events.wordpress.test/group/sunshine-coast-qld/.Note its event ID and confirm scheduling succeeded:
Expected:
1.Run
docker compose exec wordcamp.test wp cron event run --due-now, then open http://events.wordpress.test:1080/. Confirm one 📅 Auto-notify verification email was sent to each opted-in group member.Edit the published event without changing its title, run due cron again, and confirm no additional matching emails appear in MailCatcher.
Local integration verification also confirmed that initial publish queues one All Members job, while edits and republishing do not create duplicates.