bp_activity_generate_action_string( object $activity )

Generate an activity action string for an activity item.

Description

Parameters

$activity

(Required) Activity data object.

Return

(string|bool) Returns false if no callback is found, otherwise returns the formatted action string.

Source

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

1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
function bp_activity_generate_action_string( $activity ) {
 
    // Check for valid input.
    if ( empty( $activity->component ) || empty( $activity->type ) ) {
        return false;
    }
 
    // Check for registered format callback.
    $actions = bp_activity_get_actions();
    if ( empty( $actions->{$activity->component}->{$activity->type}['format_callback'] ) ) {
        return false;
    }
 
    // We apply the format_callback as a filter.
    add_filter( 'bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 );
 
    /**
     * Filters the string for the activity action being returned.
     *
     * @since BuddyPress 2.0.0
     *
     * @param BP_Activity_Activity $action   Action string being requested.
     * @param BP_Activity_Activity $activity Activity item object.
     */
    $action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
 
    // Remove the filter for future activity items.
    remove_filter( 'bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10 );
 
    return $action;
}

Changelog

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