• Resolved pd9soft

    (@pd9soft)


    WordPress configuration:
    Using the role editor
    https://wordpress.org/plugins/user-role-editor/

    This enhances the WordPress UI to support a user having multiple roles.

    Private groups configuration:

    Wordpress role “Paid member” maps to => bbppg “Paid member”
    Wordpress role “Board of directors” maps to => bbp “Board of directors”
    Wordpress role “Officer” maps to => “Officer”

    Problem:

    An example WordPress user is a member of both “Paid member” and the “Officer” roles.

    Upon login, their account is only added to the bbp “Paid member” group.

    If their WordPress roles are reduced to only a single role, “Officer” then bbp picks it up correctly and assigns them to the “Officer” bbp group.

    Summary: When a user has multiple WordPress roles, bbp does not seem to support adding them to multiple bbp private groups.

    • This topic was modified 6 years, 1 month ago by pd9soft.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter pd9soft

    (@pd9soft)

    Updated code to fix:

    function pg_set_user_group ($user_id) {
    	global $rpg_roles ;
    	$string='*' ;
    	$user_info = get_userdata($user_id);
    	if (empty ($user_info)) return ;
        $user_roles = $user_info->roles ;
    		foreach ((array)$user_roles as $list=>$role) {
    			if (!empty ($rpg_roles[$role] ) ) {
    				$group = $rpg_roles[$role] ;
    					if ($group != 'no-group' && (!empty($group)) ) {
    					$string=$string.$group.'*' ;
    					}
    			}
    		}
    	if ($string=='*') $string = '' ;
    	update_user_meta( $user_id, 'private_group', $string);
    }
    • This reply was modified 6 years, 1 month ago by pd9soft.
    Plugin Author Robin W

    (@robin-w)

    Hey thanks !

    Always love a poster who not only specifies the problem well, but then goes on to fix it !!

    I’ve very slightly changed your code, not because there was anything wrong with it, but to suit my style.

    This version will be going live next week.

    As I don’t have multiple roles on my test site, can you just confirm it works

    function pg_set_user_group ($user_id) {
    	global $rpg_roles ;
    	$string='' ;
    	$user_info = get_userdata($user_id);
    	if (empty ($user_info)) return ;
        $user_roles = $user_info->roles ;
    		foreach ((array)$user_roles as $list=>$role) {
    			if (!empty ($rpg_roles[$role] ) ) {
    				$group = $rpg_roles[$role] ;
    					if ($group != 'no-group' && (!empty($group)) ) {
    					$string.= $group.'*' ;
    					}
    			}
    		}
    	if (!empty ($string)) update_user_meta( $user_id, 'private_group', '*'.$string);
    }

    If you could it would be great, and thanks again for improving my plugin

    • This reply was modified 6 years, 1 month ago by Robin W.
    Thread Starter pd9soft

    (@pd9soft)

    Sure thing, will test it tomorrow. Glad we could get this support in the plugin!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘User with multiple roles only assigned to a single private group’ is closed to new replies.