Project23
Forum Replies Created
-
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.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 ); }