Opened 16 years ago
Closed 16 years ago
#176 closed defect (bug) (fixed)
bp not detecting user role status change to reflect contributor+ role
Reported by: | burtadsit | Owned by: | |
---|---|---|---|
Milestone: | Priority: | major | |
Severity: | Version: | ||
Component: | Keywords: | user, blogs | |
Cc: |
Description
bp isn't detecting user status changes such as moving from subscriber to contributor and reflecting that in the 'my blogs' list. We *are* recording all user blogs (roles >subscriber) for all blogs on install and when a new blog is created.
I found the bp_blogs_record_existin_blogs() function and modified it to the following:
function bp_blogs_record_existing_blogs() { global $wpdb; $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs // TRIMMED... if ( $blog_ids ) { foreach( $blog_ids as $blog_id ) { $users = get_users_of_blog( $blog_id ); if ( $users ) { foreach ( $users as $user ) { $role = unserialize( $user->meta_value ); if ( !isset( $role['subscriber'] ) ) bp_blogs_record_blog( $blog_id, $user->user_id ); else // since I can't seem to find a hook for user role update they *might* have had a diff role bp_blogs_remove_blog_for_user( $user->user_id, $blog_id ); } } } } } add_action( 'wp_login', 'bp_blogs_record_existing_blogs' );
I added a remove from bp_user_blogs call since we can't tell what the user used to be now that they are a subscriber or less they might have an orphaned rec in bp_user_blogs. Attach it to the user login action.
Better way? Be my guest. Works for me. ;)
Andy you changed this ticket from enhancement to defect. Well now the mod itself is causing a defect.
This really won't work now that you are using the bp_user_blogs table to scan for a list of blogs to output in the blog directory. It gets you duped blogs in the directory output.
I turned this off on my site and cleaned up the bp_user_blogs table of stray entries that look to the directory program as valid, unique blogs. I'm just going to implement this concept in something like a 'My Favorites' admin menu option. It'll just assume that your favs include those blogs where the user has contributor+ roles.
I had a strong suspicion that fiddling with that table would backfire. :D
I don't really know what to do with this ticket except set it to 'fixed'.