WordPress.org

Support

Support » Plugins and Hacks » BuddyPress Groupblog » [Resolved] [Plugin: BuddyPress Groupblog] user role promotion don't affect user role in blog

[Resolved] [Plugin: BuddyPress Groupblog] user role promotion don't affect user role in blog

  • When i promote a user to Admin/Moderator of the group(-blog)…
    the user role on the associated blog does’nt change.

    the roles in the group works as suspected
    and the user is correctly added to the blog…

    it’s just about changing the users role in the blog by promotion/demotion.

    Has it something to do with the “bp_groupblog_upgrade_user“-hook?
    or where/how can i add/change this to work correctly?

    Am i the onlyone having this problem?

    PS: I’m running a buddypress+bbpress+WPMU connection with subdomains-option activated

    any informations are welcome – sorry for bad english

    THX – P23

    http://wordpress.org/extend/plugins/bp-groupblog/

Viewing 6 replies - 1 through 6 (of 6 total)
  • changed some things in ‘bp-groupblog.php’:

    bp_groupblog_get_user_role() always returned ‘norole’
    so i removed the globalisation of $blog_id, because it overwrites the $blog_id given as functions argument.

    => bp_groupblog_get_user_role() now returns the right value.

    then… i also changed the bp_groupblog_upgrade_user() function.
    i removed the TRUE-Path of the first if statement, only leaving the FALSE-Path so it delivers always the LIVE group-role AFTER the promote/demote
    ($bp only delivers the role before the promotion/demotion is done)

    so this is what is left of my bp_groupblog_get_user_role() function:

    function bp_groupblog_upgrade_user( $user_id, $group_id, $blog_id = false ) {
    	global $bp;
    
    	if ( !$blog_id )
    		$blog_id = groups_get_groupmeta ( $group_id, 'groupblog_blog_id' );
    
    	// If the group has no blog linked, get the heck out of here!
    	if ( !$blog_id )
    		return;
    
    	// Set up some variables
    	$groupblog_silent_add 	       = groups_get_groupmeta ( $group_id, 'groupblog_silent_add' );
    	$groupblog_default_member_role = groups_get_groupmeta ( $group_id, 'groupblog_default_member_role' );
    	$groupblog_default_mod_role    = groups_get_groupmeta ( $group_id, 'groupblog_default_mod_role' );
    	$groupblog_default_admin_role  = groups_get_groupmeta ( $group_id, 'groupblog_default_admin_role' );
    	$groupblog_creator_role        = 'admin';
    
    	$user = new WP_User( $user_id );
    
    	$user_role = bp_groupblog_get_user_role( $user_id, $user->data->user_login, $blog_id );
    
    	// Get the current user's group status.
    
        if ( groups_is_user_admin ( $user_id, $group_id ) ) {
            $user_group_status = 'admin';
        } else if ( groups_is_user_mod ( $user_id, $group_id ) ) {
            $user_group_status = 'mod';
        } else if ( groups_is_user_member ( $user_id, $group_id ) ) {
            $user_group_status = 'member';
        } else {
            return false;
        }
    
    	switch ( $user_group_status ) {
    		case 'admin' :
    			$default_role = $groupblog_default_admin_role;
    			break;
    		case 'mod' :
    			$default_role = $groupblog_default_mod_role;
    			break;
    		case 'member' :
    		default :
    			$default_role = $groupblog_default_member_role;
    			break;
    	}
    
    	if ( $user_role == $default_role && $groupblog_silent_add == true ) {
    		return false;
    	}
    
    	if ( !$groupblog_silent_add ) {
    		$default_role = 'subscriber';
    	}
    
    	add_user_to_blog( $blog_id, $user_id, $default_role );
    
    	do_action( 'bp_groupblog_upgrade_user', $user_id, $user_role, $default_role );
    }

    so this is what is left of my bp_groupblog_get_user_role() function:

    my fault… as you see in the code-section, the secound part is about the bp_groupblog_upgrade_user() function.

    Plugin Author Boone Gorges

    @boonebgorges

    Project23 – Thanks very much for doing this research. I’ve opened a ticket so that I don’t lose track of this: https://github.com/boonebgorges/bp-groupblog/issues/13

    Project23 – thanks, your amends to bp_groupblog_upgrade_user() work perfectly.

    BTW, you’ll find if you use a non-default $table_prefix in wp-config.php that removing the reference to the global in bp_groupblog_get_user_role() is not quite enough. See my fix on Github.

    Plugin Author Boone Gorges

    @boonebgorges

    needle – Awesome, that fix should definitely go in too.

    This is a very helpful improvement. Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] [Plugin: BuddyPress Groupblog] user role promotion don't affect user role in blog’ is closed to new replies.
Skip to toolbar