bp_dd_import_users_friends()

Get random users from the DB and generate member connections.

Description

Return

(int)

Source

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

function bp_dd_import_users_friends() {
	$count = 0;

	if ( ! bp_is_active( 'friends' ) ) {
		return $count;
	}

	$users = bp_dd_get_random_users_ids( 50 );

	add_filter( 'bp_core_current_time', 'bp_dd_friends_add_friend_date_fix' );

	for ( $i = 0; $i < 100; $i ++ ) {
		$user_one = $users[ array_rand( $users ) ];
		$user_two = $users[ array_rand( $users ) ];

		// Make them friends if possible.
		if ( friends_add_friend( $user_one, $user_two, true ) ) {
			$count ++;
		}
	}

	remove_filter( 'bp_core_current_time', 'bp_dd_friends_add_friend_date_fix' );

	return $count;
}

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.