Changeset 4759
- Timestamp:
- 02/07/2013 01:59:43 AM (13 years ago)
- Location:
- branches/2.2/includes
- Files:
-
- 2 edited
-
core/capabilities.php (modified) (1 diff)
-
users/capabilities.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/includes/core/capabilities.php
r4453 r4759 336 336 $wp_roles->role_names[$role_id] = $details['name']; 337 337 } 338 339 return $wp_roles; 338 340 } 339 341 -
branches/2.2/includes/users/capabilities.php
r4449 r4759 82 82 // Add the new role 83 83 if ( !empty( $new_role ) ) { 84 85 // Make sure bbPress roles are added 86 bbp_add_forums_roles(); 87 84 88 $user->add_role( $new_role ); 85 89 } … … 137 141 */ 138 142 function bbp_get_user_blog_role( $user_id = 0 ) { 139 global $wp_roles; 140 141 // This really shold not be necessary anymore, and will likely be removed 142 // at a later date. If roles aren't loaded yet, something else is wrong. 143 if ( ! isset( $wp_roles ) ) 144 $wp_roles = new WP_Roles(); 143 144 // Add bbPress roles (returns $wp_roles global) 145 $wp_roles = bbp_add_forums_roles(); 145 146 146 147 // Validate user id … … 164 165 165 166 /** 166 * Helper function hooked to 'bbp_ edit_user_profile_update' action to save or167 * Helper function hooked to 'bbp_profile_update' action to save or 167 168 * update user roles and capabilities. 168 169 * … … 187 188 $forums_role = bbp_get_user_role( $user_id ); 188 189 190 // Bail if no role change 191 if ( $new_role == $forums_role ) 192 return; 193 194 // Bail if trying to set their own role 195 if ( bbp_is_user_home_edit() ) 196 return; 197 198 // Bail if current user cannot promote the passing user 199 if ( ! current_user_can( 'promote_user', $user_id ) ) 200 return; 201 189 202 // Set the new forums role 190 if ( $new_role != $forums_role ) { 191 bbp_set_user_role( $user_id, $new_role ); 192 } 203 bbp_set_user_role( $user_id, $new_role ); 193 204 } 194 205 … … 267 278 // Add the user to the site 268 279 if ( true == $add_to_site ) { 280 281 // Make sure bbPress roles are added 282 bbp_add_forums_roles(); 283 269 284 $bbp->current_user->add_role( $new_role ); 270 285 271 286 // Don't add the user, but still give them the correct caps dynamically 272 } else { 287 } else { 273 288 $bbp->current_user->caps[$new_role] = true; 274 289 $bbp->current_user->get_role_caps(); … … 370 385 // Bail if no user ID 371 386 if ( empty( $user_id ) ) 372 return ;387 return false; 373 388 374 389 // Bail if user ID is super admin 375 390 if ( is_super_admin( $user_id ) ) 376 return ;391 return false; 377 392 378 393 // Arm the torpedos … … 422 437 restore_current_blog(); 423 438 } 439 440 // Success 441 return true; 424 442 } 425 443 … … 455 473 // Bail if no user ID 456 474 if ( empty( $user_id ) ) 457 return ;475 return false; 458 476 459 477 // Bail if user ID is super admin 460 478 if ( is_super_admin( $user_id ) ) 461 return ;479 return false; 462 480 463 481 // Arm the torpedos … … 507 525 restore_current_blog(); 508 526 } 527 528 // Success 529 return true; 509 530 } 510 531
Note: See TracChangeset
for help on using the changeset viewer.