groups_record_activity( array|string $args = '' )

Record an activity item related to the Groups component.


Description Description

A wrapper for bp_activity_add() that provides some Groups-specific defaults.

See also See also


Top ↑

Parameters Parameters

$args

(Optional) An array of arguments for the new activity item. Accepts all parameters of bp_activity_add(). However, this wrapper provides some additional defaults, as described below:

  • 'component'
    (string) Default: the id of your Groups component (usually 'groups').
  • 'hide_sitewide'
    (bool) Default: True if the current group is not public, otherwise false.

Default value: ''


Top ↑

Return Return

(WP_Error|bool|int) See bp_activity_add().


Top ↑

Source Source

File: bp-groups/bp-groups-activity.php

function groups_record_activity( $args = '' ) {

	if ( ! bp_is_active( 'activity' ) ) {
		return false;
	}

	// Set the default for hide_sitewide by checking the status of the group.
	$hide_sitewide = false;
	if ( ! empty( $args['item_id'] ) ) {
		$group = bp_groups_get_activity_group( $args['item_id'] );

		if ( isset( $group->status ) && 'public' != $group->status ) {
			$hide_sitewide = true;
		}
	}

	$r = bp_parse_args( $args, array(
		'id'                => false,
		'user_id'           => bp_loggedin_user_id(),
		'action'            => '',
		'content'           => '',
		'primary_link'      => '',
		'component'         => buddypress()->groups->id,
		'type'              => false,
		'item_id'           => false,
		'secondary_item_id' => false,
		'recorded_time'     => bp_core_current_time(),
		'hide_sitewide'     => $hide_sitewide,
		'error_type'        => 'bool'
	), 'groups_record_activity' );

	return bp_activity_add( $r );
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.