Skip to content

fix(rsvp): keep plugin avatars on RSVPs, mask anonymous ones - #2652

Open
faisalahammad wants to merge 1 commit into
GatherPress:developfrom
faisalahammad:fix/2575-rsvp-avatar-visibility
Open

faisalahammad wants to merge 1 commit into
GatherPress:developfrom
faisalahammad:fix/2575-rsvp-avatar-visibility

Conversation

@faisalahammad

Copy link
Copy Markdown
Contributor

Fixes #2575

Proposed changes:

  • gatherpress_rsvp is now added to the get_avatar_comment_types filter, so core resolves RSVP avatars like it does for normal comments. Before this, core skipped the RSVP type and Rsvp_Response::modify_avatar_for_gatherpress_rsvp() always set the avatar URL itself, which replaced avatars from other plugins (for example local avatar plugins using pre_get_avatar_data), even for admins.
  • modify_avatar_for_gatherpress_rsvp() now only steps in for an anonymous RSVP when the viewer cannot moderate_comments. In that case it forces the default avatar. This is still needed because the masked comment keeps its user_id, so core alone would find the real avatar.
  • Added docblocks to Rsvp::process() and constrain_rsvp_intent() explaining that an anonymous request is saved as public when the event does not allow anonymous RSVPs, and that callers must check gatherpress_enable_anonymous_rsvp before calling process() if that matters to them.
  • Added a "Visibility and anonymous RSVPs" section to docs/developer/rsvp/README.md covering the single capability rule, where masking happens, and the avatar flow.

Small behavior change: RSVP avatars now follow the site's default avatar setting, so an RSVP with no account and no email gets that default instead of a forced "mystery" image.

Other information:

  • Have you written new tests for your changes, if applicable?

AI assistance

  • An AI tool wrote a significant part of this change.

Testing instructions:

Setup: "Show Avatars" on in Settings > Discussion, one event with RSVPs and "Enable Anonymous RSVP" checked, an admin and two subscribers (A and B).

  1. As subscriber A, RSVP "Attending" normally. As subscriber B, RSVP "Attending" with "List me as anonymous" checked.

  2. Log out and view the event. A shows their Gravatar. B shows as "Anonymous" with the default avatar.

  3. Log in as subscriber A. B is still "Anonymous" with the default avatar.

  4. Log in as admin. B shows their real name and Gravatar.

  5. Add this mu-plugin (wp-content/mu-plugins/test-avatar.php) or use a local avatar plugin:

    <?php
    add_filter( 'pre_get_avatar_data', function ( $args, $id_or_email ) {
    	if ( $id_or_email instanceof WP_Comment ) {
    		$args['url']          = 'https://placehold.co/96x96/ff0000/ffffff?text=OK';
    		$args['found_avatar'] = true;
    	}
    	return $args;
    }, 10, 2 );
  6. Log out and view the event. A shows the red "OK" avatar (before this fix it was replaced with the Gravatar). B still shows the default avatar.

  7. Log in as admin. Both A and B show the red "OK" avatar.

  8. Open the event's RSVP attendee list in admin. Avatars show for every RSVP.

  9. Leave a normal comment on a post. Its avatar shows as before.

Credit (for release notes)

My WordPress.org username: faisal03

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Changelog entry is committed in .github/changelog/2575-rsvp-avatar-visibility.

- Register gatherpress_rsvp as an avatar comment type so core resolves RSVP avatars
- Only replace the avatar for anonymous RSVPs seen without moderate_comments
- Document RSVP visibility and the anonymous downgrade in process()

Fixes GatherPress#2575
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown
Contributor

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props faisalahammad, andremenrath.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

Copy link
Copy Markdown
Contributor

Test Coverage Report

✅ All coverage checks passed!

✅ PHP Coverage
=== PR Coverage Check ===

Configuration loaded:
  Minimum coverage: 100%
  Exclude patterns: 47 patterns
  Low coverage exceptions: 0 files

Checking coverage for files changed from origin/develop...

Found 3 changed PHP file(s):
  - includes/core/classes/blocks/class-rsvp-response.php
  - includes/core/classes/rsvp/class-rsvp.php
  - test/unit/php/includes/tests/core/classes/blocks/class-test-rsvp-response.php

Files requiring coverage check: 2
  - includes/core/classes/blocks/class-rsvp-response.php
  - includes/core/classes/rsvp/class-rsvp.php

✅ Loaded coverage.xml
✅ Loaded coverage-multisite.xml

✅ includes/core/classes/blocks/class-rsvp-response.php - 100% coverage (152/152 lines)
✅ includes/core/classes/rsvp/class-rsvp.php - 100% coverage (230/230 lines)

=== Summary ===
✅ Passed: 2 file(s)
⏭️  Excluded: 1 file(s)
❌ Failed: 0 file(s)

✅ All changed files meet the minimum coverage requirement of 100%
✅ JavaScript Coverage
=== PR JavaScript Coverage Check ===

Configuration loaded:
  Minimum coverage: 100%
  Exclude patterns: 47 patterns

Checking coverage for JavaScript files changed from origin/develop...

✅ No JavaScript files changed in this PR.

This comment is automatically updated on each push.

@mauteri mauteri added this to the 0.38.0 milestone Nov 17, 2026

@wppoland wppoland 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.

LGTM! Registering gatherpress_rsvp via get_avatar_comment_types so core resolves RSVP avatars directly (and preserves third-party pre_get_avatar_data providers like local avatar plugins), while only masking with force_default => true and found_avatar => false in modify_avatar_for_gatherpress_rsvp() when gatherpress_rsvp_anonymous is set and the viewer lacks Rsvp::CAPABILITY, is a much cleaner design. The new developer documentation section and unit tests look great too.

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.

Improve visibility handling of RSVPs

3 participants