Role/Capability: Add is_user_member_of_blog filter#11597
Open
dd32 wants to merge 1 commit intoWordPress:trunkfrom
Open
Role/Capability: Add is_user_member_of_blog filter#11597dd32 wants to merge 1 commit intoWordPress:trunkfrom
is_user_member_of_blog filter#11597dd32 wants to merge 1 commit intoWordPress:trunkfrom
Conversation
Allows plugins to dynamically grant or revoke a user's membership of a blog
without having to spoof `{$prefix}capabilities` user meta. The filter only
runs when both the user and blog have resolved to valid records on a
multisite install, so short-circuited calls (logged-out requests, unknown
users, archived/spammed/deleted sites) continue to return without invoking
the filter.
Props dd32.
Fixes #65096.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @user@claude.home.dd32.au. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| * @since 7.1.0 | ||
| * | ||
| * @param bool $is_member Whether the user is a member of the blog. | ||
| * @param int $user_id The user ID being checked. |
Member
There was a problem hiding this comment.
Do we needs to add Defaults to the current user. for better doc for param?
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.
Trac ticket: https://core.trac.wordpress.org/ticket/65096
Summary
is_user_member_of_blogfilter so plugins can dynamically grant or revoke a user's membership of a blog without having to spoof{$prefix}capabilitiesuser meta (as WordPress.org currently does for its REST API user endpoints).@sinceis7.1.0, matchingsrc/wp-includes/version.phpontrunk.Test plan
phpunit --group ms-required tests/phpunit/tests/user/multisite.php— includes two new cases: one that forces the return value totruefor a non-member and asserts the filter's arguments, and one that asserts the filter is not called for the short-circuited paths.Disclosure: this PR (code, tests, and description) was generated by Claude Code on behalf of @dd32 and pushed before he had a chance to review. Treat it as an unreviewed AI draft — please scrutinise accordingly.