Changeset 4364
- Timestamp:
- 11/09/2012 09:26:57 AM (12 years ago)
- Location:
- trunk/includes/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/core/actions.php
r4360 r4364 69 69 add_action( 'bbp_loaded', 'bbp_register_theme_packages', 14 ); 70 70 add_action( 'bbp_loaded', 'bbp_load_textdomain', 16 ); 71 add_action( 'bbp_loaded', 'bbp_filter_user_roles_option', 18 ); 71 72 72 73 /** -
trunk/includes/core/capabilities.php
r4354 r4364 37 37 case bbp_get_keymaster_role() : 38 38 $caps = array( 39 40 // Keymasters only 41 'keep_gate' => true, 39 42 40 43 // Primary caps … … 337 340 338 341 /** 342 * Helper function to add filter to option_wp_user_roles 343 * 344 * @since bbPress (r4363) 345 * 346 * @see _bbp_reinit_dynamic_roles() 347 * 348 * @global WPDB $wpdb Used to get the database prefix 349 */ 350 function bbp_filter_user_roles_option() { 351 global $wpdb; 352 353 $role_key = $wpdb->prefix . 'user_roles'; 354 355 add_filter( 'option_' . $role_key, '_bbp_reinit_dynamic_roles' ); 356 } 357 358 /** 359 * This is necessary because in a few places (noted below) WordPress initializes 360 * a blog's roles directly from the database option. When this happens, the 361 * $wp_roles global gets flushed, causing a user to magically lose any 362 * dynamically assigned roles or capabilities when $current_user in refreshed. 363 * 364 * Because dynamic multiple roles is a new concept in WordPress, we work around 365 * it here for now, knowing that improvements will come to WordPress core later. 366 * 367 * @see switch_to_blog() 368 * @see restore_current_blog() 369 * @see WP_Roles::_init() 370 * 371 * @since bbPress (r4363) 372 * 373 * @internal Used by bbPress to reinitialize dynamic roles on blog switch 374 * 375 * @param array $roles 376 * @return array Combined array of database roles and dynamic bbPress roles 377 */ 378 function _bbp_reinit_dynamic_roles( $roles = array() ) { 379 foreach( bbp_get_dynamic_roles() as $role_id => $details ) { 380 $roles[$role_id] = $details; 381 } 382 return $roles; 383 } 384 385 /** 339 386 * Fetch a filtered list of forum roles that the current user is 340 387 * allowed to have.
Note: See TracChangeset
for help on using the changeset viewer.