bp_dd_import_groups_activity()

Import groups activity – aka “status updates”.

Description

Return

(int)

Source

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

function bp_dd_import_groups_activity() {
	$count = 0;

	if ( ! bp_is_active( 'groups' ) || ! bp_is_active( 'activity' ) ) {
		return $count;
	}

	$users  = bp_dd_get_random_users_ids( 0 );
	$groups = bp_dd_get_random_groups_ids( 0 );

	/** @var $activity array */
	require( BP_DEFAULT_DATA_DIR . 'data/activity.php' );

	for ( $i = 0; $i < 150; $i ++ ) {
		$user_id  = $users[ array_rand( $users ) ];
		$group_id = $groups[ array_rand( $groups ) ];
		$content  = $activity[ array_rand( $activity ) ];

		if ( ! groups_is_user_member( $user_id, $group_id ) ) {
			continue;
		}

		if ( $bp_activity_id = groups_post_update( array(
			'user_id'  => $user_id,
			'group_id' => $group_id,
			'content'  => $content,
		) )
		) {
			$bp_activity                = new BP_Activity_Activity( $bp_activity_id );
			$bp_activity->date_recorded = bp_dd_get_random_date( 29 );
			if ( $bp_activity->save() ) {
				$count ++;
			}
		}
	}

	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.