Changeset 5632
- Timestamp:
- 07/08/2017 11:09:18 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php
r5631 r5632 128 128 * an Administrator role on the site. 129 129 * 130 * @param array $caps User's actual capabilities.131 * @param string $cap Capability name.132 * @param int $ user_id Current user ID.133 * @param array $args Capability context, typically the object ID.130 * @param array $caps User's actual capabilities. 131 * @param string $cap Capability name. 132 * @param int $current_user_id Current user ID. 133 * @param array $args Capability context, typically the object ID. 134 134 * @return array Filtered capabilities. 135 135 */ 136 function map_meta_caps( $caps, $cap, $ user_id, $args ) {136 function map_meta_caps( $caps, $cap, $current_user_id, $args ) { 137 137 switch ( $cap ) { 138 138 case 'promote_user': 139 139 case 'promote_users': 140 // Only keymasters can promote users.141 $caps = array( 'keep_gate' );142 break;143 144 140 case 'edit_user': 145 141 case 'edit_users': 146 142 // Bail before "User Role" section is displayed. 147 143 // See https://bbpress.trac.wordpress.org/ticket/3126 148 if ( did_action( 'bbp_user_edit_after_account' ) && ! bbp_is_user_keymaster( $ user_id ) ) {144 if ( did_action( 'bbp_user_edit_after_account' ) && ! bbp_is_user_keymaster( $current_user_id ) ) { 149 145 return $caps; 150 146 } 151 147 152 148 // Get the user ID. 153 $ _user_id= ! empty( $args[0] )149 $user_id_to_check = ! empty( $args[0] ) 154 150 ? (int) $args[0] 155 151 : bbp_get_displayed_user_id(); 156 152 157 153 // Users can always edit themselves, so only map for others. 158 if ( ! empty( $_user_id ) && ( $_user_id !== $user_id ) ) { 159 154 if ( ! empty( $user_id_to_check ) && ( $user_id_to_check !== $current_user_id ) ) { 160 155 // Moderators cannot edit keymasters. 161 if ( ! bbp_is_user_keymaster( $_user_id ) ) { 156 if ( bbp_is_user_keymaster( $user_id_to_check ) ) { 157 return $caps; 158 } 159 160 // Moderators and keymasters cannot edit admins or super admins, unless they have the same role. 161 if ( user_can( $user_id_to_check, 'manage_options' ) || is_super_admin( $user_id_to_check ) ) { 162 return $caps; 163 } 164 165 if ( 'promote_user' === $cap || 'promote_users' === $cap ) { 166 // Only keymasters can promote users. 167 $caps = array( 'keep_gate' ); 168 } else { 162 169 $caps = array( 'moderate' ); 163 170 }
Note: See TracChangeset
for help on using the changeset viewer.