Changeset 6844
- Timestamp:
- 03/09/2013 08:43:38 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-caps.php
r6306 r6844 210 210 * @since BuddyPress (1.6) 211 211 * @see WP_User::has_cap() 212 * @access private 212 213 * 213 214 * @param array $allcaps The caps that WP associates with the given role … … 216 217 * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant 217 218 */ 218 function _bp_enforce_bp_moderate_cap_for_admins( $allcaps, $caps, $args ) { 219 if ( in_array( 'bp_moderate', $caps ) && // We only care if checking for bp_moderate 220 !in_array( 'do_not_allow', $caps ) && // 'do_not_allow' overrides everything else 221 !is_multisite() && // Check not necessary on Multisite 222 isset( $allcaps['delete_users'] ) ) // Mimicking WP's check for Administrator status 223 { 224 $allcaps['bp_moderate'] = true; 225 } 226 227 return $allcaps; 228 } 229 add_filter( 'user_has_cap', '_bp_enforce_bp_moderate_cap_for_admins', 10, 3 ); 219 function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) { 220 221 // Bail if not checking the 'bp_moderate' cap 222 if ( 'bp_moderate' !== $cap ) 223 return $caps; 224 225 // Bail if BuddyPress is not network activated 226 if ( bp_is_network_activated() ) 227 return $caps; 228 229 // Never trust inactive users 230 if ( bp_is_user_inactive( $user_id ) ) 231 return $caps; 232 233 // Only users that can 'manage_options' on this site can 'bp_moderate' 234 return array( 'manage_options' ); 235 } 236 add_filter( 'map_meta_cap', '_bp_enforce_bp_moderate_cap_for_admins', 10, 4 ); 230 237 231 238 /** Deprecated ****************************************************************/
Note: See TracChangeset
for help on using the changeset viewer.