Skip to:

Add all member of group X to group Y

  • Hiya!

    I have a quirky need. ;) I have members of group X (private) that I need to add to group Y. I do have the Group management plugin, but I;d rather not go through one list in one tab and add them in another. Tedious, but it would work.

    Any ideas? I only need to do this once. Not for future group members, just existing.

Viewing 2 replies - 1 through 2 (of 2 total)

  • Boone Gorges


    Hi Andrea,

    Maybe not the most straightforward method, but a loop roughly like this would do it:
    `if ( bp_group_has_members( array( ‘group_id’ => $group_x_id, ‘per_page’ => 100000 ) ) ) {
    while ( bp_group_members() ) {

    $user_id = bp_get_group_member_id();

    // Don’t do this if the user is already a member
    if ( groups_is_user_member( $user_id, $group_y_id ) ) {

    $new_member = new BP_Groups_Member;
    $new_member->group_id = $group_y_id;
    $new_member->user_id = $user_id;
    $new_member->inviter_id = 0;
    $new_member->is_admin = 0;
    $new_member->user_title = ”;
    $new_member->date_modified = bp_core_current_time();
    $new_member->is_confirmed = 1;


    groups_update_groupmeta( $group_y_id, ‘total_member_count’, (int) groups_get_groupmeta( $group_y_id, ‘total_member_count’) + 1 );

    I haven’t tested that, but something very much like it should work.

    Cool beans! Thanks, luvvy. I’ll give it a try and let you know.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add all member of group X to group Y’ is closed to new replies.
Skip to toolbar