bp_dd_import_groups_members( bool $groups = false )

Import groups members.

Description

Parameters

$groups

(Optional) We can import random groups or work with a predefined list.

Default value: false

Return

(array)

Source

File: bp-core/bp-core-tools-default-data.php

function bp_dd_import_groups_members( $groups = false ) {
	$members = array();

	if ( ! bp_is_active( 'groups' ) ) {
		return $members;
	}

	if ( ! $groups ) {
		$groups = bp_dd_get_random_groups_ids( 0 );
	}

	add_filter( 'bp_after_activity_add_parse_args', 'bp_dd_groups_join_group_date_fix' );

	foreach ( $groups as $group_id ) {
		$user_ids = bp_dd_get_random_users_ids( mt_rand( 2, 15 ) );

		foreach ( $user_ids as $user_id ) {
			if ( groups_join_group( $group_id, $user_id ) ) {
				$members[] = $group_id;
			}
		}
	}

	remove_filter( 'bp_after_activity_add_parse_args', 'bp_dd_groups_join_group_date_fix' );

	return $members;
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.