Skip to:
Content

BuddyPress.org

Changeset 3469


Ignore:
Timestamp:
11/21/2010 11:04:45 PM (15 years ago)
Author:
boonebgorges
Message:

Adds blog to user's BP blog list (in particular, for the root blog) when user is added through the Dashboard by the Super Admin. Fixes #2137

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs.php

    r3434 r3469  
    468468add_action( 'wp_set_comment_status', 'bp_blogs_manage_comment', 10, 2 );
    469469
    470 function bp_blogs_add_user_to_blog( $user_id, $role, $blog_id = false ) {
    471     global $current_blog;
     470function bp_blogs_add_user_to_blog( $user_id, $role = false, $blog_id = false ) {
     471    global $wpdb, $current_blog;
    472472
    473473    if ( empty( $blog_id ) )
    474474        $blog_id = $current_blog->blog_id;
    475475
     476    if ( empty( $role ) ) {
     477        $key = $wpdb->get_blog_prefix( $id ). 'capabilities';
     478       
     479        $roles = get_user_meta( $user_id, $key, true );
     480       
     481        if ( is_array( $roles ) )
     482            $role = array_search( 1, $roles );
     483        else
     484            return false;
     485    }
     486
    476487    if ( $role != 'subscriber' )
    477488        bp_blogs_record_blog( $blog_id, $user_id, true );
    478489}
    479490add_action( 'add_user_to_blog', 'bp_blogs_add_user_to_blog', 10, 3 );
     491add_action( 'profile_update', 'bp_blogs_add_user_to_blog' );
     492add_action( 'user_register', 'bp_blogs_add_user_to_blog' );
    480493
    481494function bp_blogs_remove_user_from_blog( $user_id, $blog_id = false ) {
Note: See TracChangeset for help on using the changeset viewer.