groups_record_activity( array|string $args = '' )

Record an activity item related to the Groups component.

Description

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

See also

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: ''

Return

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

Source

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

442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
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'] ) ) {
        if ( bp_get_current_group_id() == $args['item_id'] ) {
            $group = groups_get_current_group();
        } else {
            $group = groups_get_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,
        'privacy'           => 'public',
        'error_type'        => 'bool'
    ), 'groups_record_activity' );
 
    return bp_activity_add( $r );
}

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.