bp_blogs_record_activity( array|string $args = '' )

Record blog-related activity to the activity feed.

Description

See also

Parameters

$args

(Optional) See bp_activity_add() for complete description of arguments. The arguments listed here have different default values from bp_activity_add().

  • 'component'
    (string) Default: 'blogs'.

Default value: ''

Return

(WP_Error|bool|int) On success, returns the activity ID. False on failure.

Source

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

function bp_blogs_record_activity( $args = '' ) {
	$defaults = array(
		'user_id'           => bp_loggedin_user_id(),
		'action'            => '',
		'content'           => '',
		'primary_link'      => '',
		'component'         => buddypress()->blogs->id,
		'type'              => false,
		'item_id'           => false,
		'secondary_item_id' => false,
		'recorded_time'     => bp_core_current_time(),
		'hide_sitewide'     => false
	);

	$r = wp_parse_args( $args, $defaults );

	if ( ! empty( $r['action'] ) ) {

		/**
		 * Filters the action associated with activity for activity feed.
		 *
		 * @since BuddyPress 1.2.0
		 *
		 * @param string $value Action for the activity feed.
		 */
		$r['action'] = apply_filters( 'bp_blogs_record_activity_action', $r['action'] );
	}

	if ( ! empty( $r['content'] ) ) {

		/**
		 * Filters the content associated with activity for activity feed.
		 *
		 * @since BuddyPress 1.2.0
		 *
		 * @param string $value Generated summary from content for the activity feed.
		 * @param string $value Content for the activity feed.
		 * @param array  $r     Array of arguments used for the activity feed item.
		 */
		$r['content'] = apply_filters( 'bp_blogs_record_activity_content', bp_activity_create_summary( $r['content'], $r ), $r['content'], $r );
	}

	// Check for an existing entry and update if one exists.
	$id = bp_activity_get_activity_id( array(
		'user_id'           => $r['user_id'],
		'component'         => $r['component'],
		'type'              => $r['type'],
		'item_id'           => $r['item_id'],
		'secondary_item_id' => $r['secondary_item_id'],
	) );

	return bp_activity_add( array( 'id' => $id, 'user_id' => $r['user_id'], 'action' => $r['action'], 'content' => $r['content'], 'primary_link' => $r['primary_link'], 'component' => $r['component'], 'type' => $r['type'], 'item_id' => $r['item_id'], 'secondary_item_id' => $r['secondary_item_id'], 'recorded_time' => $r['recorded_time'], 'hide_sitewide' => $r['hide_sitewide'] ) );
}

Changelog

Changelog
Version Description
BuddyPress 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.