fix: allow admins to edit other users' settings#4934
fix: allow admins to edit other users' settings#4934GaryJones wants to merge 159 commits intobuddyboss:releasefrom
Conversation
# Conflicts: # src/languages/buddyboss.pot
# Conflicts: # src/languages/buddyboss.pot
* release: (57 commits) grunt release grunt Update: Grunt string-replace version bump grunt Exclude vendor for checktextdomain cleanup repo shows action count as unlimited grunt fix updated URL to be production one implement copy clipboard to the licence key Fix the fields to show text changes Created popup for free licence licence creation Implement cache for the fetch license details added a free plugin id update condition to show the bb header in admin updated code to check the add on available or not restructure licence information added lciense info ... # Conflicts: # src/composer.lock
* release: grunt release version bump grunt Added change log PROD-9249 - fix the issue to check the issue exists and must be array befor array_merge PROD-9249 - run migration for admin only PROD-9249 - updated the mothership load priority composer update
* release: grunt release version bump and added change log grunt Fix deprecation: Use AbstractPluginConnection::class instead of CONNECTION_PLUGIN_SERVICE_ID break the loop when ilcense activated improve error validation on migration update the code to run once on update specific version removed unused things fix the connector Called migration on plugin update only Deprecated: BuddyBossPlatform\GroundLevel\Mothership\Service::CONNECTION_PLUGIN_SERVICE_ID() fix the error display issue
* release: grunt release grunt version bump and added change log PROD-9260 - restrict few items to be admin specific PROD-9260 - Fix the issue about to work the pro feature on frontend
* release: grunt release grunt version bump and added change log [PROD-9270] Composer update to fix the issue with the theme update issue
The elseif branch `bp_is_user() && ! bp_is_my_profile()` in bp_core_can_edit_settings() catches all cases where a user views another user's profile, setting status to false before the bp_moderate / edit_users capability check is reached. This prevents administrators from editing other members' settings on the front end. The branch is also redundant since $status is already initialised to false. Removing it restores the logic to match upstream BuddyPress, where the capability check is correctly evaluated. Fixes buddyboss#4933
|
@claude Review the PR |
|
Claude finished @chetansatasiya's task in 1m 29s —— View job PR Review: fix: allow admins to edit other users' settings
SummaryThis is a clean, correct fix. The removed branch introduced a subtle logic bug that silently short-circuited the Logic AnalysisBefore (buggy): $status = false;
if ( bp_is_my_profile() ) {
$status = true;
} elseif ( bp_is_user() && ! bp_is_my_profile() ) {
$status = false; // ← catches ALL "other user" cases here
} elseif ( is_super_admin( bp_displayed_user_id() ) && ! is_super_admin() ) {
$status = false; // ← UNREACHABLE when on another user's profile
} elseif ( bp_current_user_can( 'bp_moderate' ) || current_user_can( 'edit_users' ) ) {
$status = true; // ← UNREACHABLE when on another user's profile
}When an admin visits
After (fixed): $status = false;
if ( bp_is_my_profile() ) {
$status = true;
} elseif ( is_super_admin( bp_displayed_user_id() ) && ! is_super_admin() ) {
$status = false; // Prevent non-super-admins from editing super admins
} elseif ( bp_current_user_can( 'bp_moderate' ) || current_user_can( 'edit_users' ) ) {
$status = true; // ← Now reachable for admins on other users' profiles
}Correctness of All Cases
Redundancy of the Removed BranchThe removed branch was also logically redundant. Scope of Impact
VerdictApprove. The fix is minimal, correct, and matches the description. The PR author correctly identifies both the bug cause (premature One minor observation — not a blocker: the |
Description
bp_core_can_edit_settings()has a logic error that prevents administrators from editing other users' settings on the front end. Theelseif ( bp_is_user() && ! bp_is_my_profile() )branch catches all "other user" cases, setting$status = falsebefore thebp_moderate/edit_userscapability check is ever reached.This branch is also redundant —
$statusis already initialised tofalse, so non-admin users viewing other profiles already getfalsewithout needing an explicit branch.Removing the branch restores the logic to match upstream BuddyPress.
Fixes #4933
Steps to reproduce (before fix)
/members/other-user/profile/edit/Expected behaviour (after fix)
Administrators with
bp_moderateoredit_userscapability can edit other members' profile fields on the front end, as intended by the capability check that was previously unreachable.