bp_dd_import_users_activity()

Import Activity – aka “status updates”.

Description

Return

(int) Number of activity records that were inserted into the database.

Source

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

function bp_dd_import_users_activity() {
	$count = 0;

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

	$users = bp_dd_get_random_users_ids( 0 );

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

	for ( $i = 0; $i < 75; $i ++ ) {
		$user    = $users[ array_rand( $users ) ];
		$content = $activity[ array_rand( $activity ) ];

		if ( $bp_activity_id = bp_activity_post_update( array(
			'user_id' => $user,
			'content' => $content,
		) )
		) {
			$bp_activity                = new BP_Activity_Activity( $bp_activity_id );
			$bp_activity->date_recorded = bp_dd_get_random_date( 44 );
			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.