Skip to content

Groups: notify members when events are published - #1829

Open
gedex wants to merge 2 commits into
WordPress:productionfrom
gedex:issue-1773-auto-notify-new-events
Open

Groups: notify members when events are published#1829
gedex wants to merge 2 commits into
WordPress:productionfrom
gedex:issue-1773-auto-notify-new-events

Conversation

@gedex

@gedex gedex commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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

  1. Run npm run build, then create and publish an event titled Auto-notify verification for https://events.wordpress.test/group/sunshine-coast-qld/.

    image

  2. Note its event ID and confirm scheduling succeeded:

    docker compose exec wordcamp.test wp post meta get <EVENT_ID> \
      _wporg_groups_event_publish_notification_scheduled \
      --url=https://events.wordpress.test/group/sunshine-coast-qld/

    Expected: 1.

  3. 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.

    image

  4. 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.

@gedex gedex self-assigned this Jul 30, 2026
@gedex
gedex requested review from bor0, Copilot and raicem July 30, 2026 12:59
@gedex
gedex marked this pull request as ready for review July 30, 2026 13:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-frontend mu-plugin bootstrap.
  • Registers a transition_post_status hook to schedule the gatherpress_send_emails cron 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;
}
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.

Auto-notify members when a new event is published

3 participants