Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Participation Notifier: remove the old user's badge when the username…
… changes

Moving badge handling to wp_after_insert_post dropped the only code that
took the badge off the previous user when a published speaker or
organizer's WordPress.org username changed. Keep that removal in
username_meta_update(); the new user still gets theirs on save.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
  • Loading branch information
gedex and claude committed Sep 25, 2026
commit 798437f8abe60fc1b2e599f35cb5ecdfbdae556b
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function is_post_notifiable( $post ) {
}

/**
* Maybe add mentor activity when the User ID meta is updated.
* Remove the old user's badge when a published post's User ID changes, and maybe add mentor activity.
*
* @param int $meta_id ID of the metadata entry to update.
* @param int $object_id ID of the object metadata is for.
Expand All @@ -109,6 +109,15 @@ public function username_meta_update( $meta_id, $object_id, $meta_key, $meta_val
$post = get_post( $object_id );
$prev_value = get_post_meta( $object_id, $meta_key, true );

Comment thread
gedex marked this conversation as resolved.
// The new user gets their badge from maybe_notify_on_post_save(); the old one loses it here.
if ( '_wcpt_user_id' === $meta_key && 'publish' === $post->post_status ) {
$prev_user_id = absint( $prev_value );

if ( $prev_user_id && absint( $meta_value ) !== $prev_user_id ) {
$this->maybe_remove_badge( $post, $prev_user_id );
}
}

if ( 'Mentor WordPress.org User Name' === $meta_key && $meta_value && $prev_value !== $meta_value ) {
// Username has already been validated by `Event_Admin::metabox_save()`.
$this->add_activity( $post, $meta_value, 'mentor_assign' );
Expand Down
Loading