bp_activity_set_action()

bp_activity_set_action() is used to set activity actions. bp_activity_set_action() should only be invoked through the ‘bp_register_activity_actions’ action.

Usage Usage

[code language=”php”]
function custom_plugin_register_activity_actions() {
// Your plugin is creating a custom BuddyPress component
$component_id = ‘plugin_component_id’;
// You can also use one of the BuddyPress component
// $component_id = buddypress()->activity->id;

bp_activity_set_action(
$component_id,
‘plugin_action’,
__( ‘Did a plugin action’, ‘plugin-domain’ ),
‘plugin_format_activity_action_plugin_action’,
__( ‘Plugin actions’, ‘plugin-domain’ ),
array( ‘member’ )
);
}
add_action( ‘bp_register_activity_actions’, ‘custom_plugin_register_activity_actions’ );
[/code]

Top ↑

Parameters Parameters

$component_id
The unique string ID of the component the activity action is attached to. Possible values can be one of the BuddyPress optional components or an optional component the plugin is creating :

  • 'activity'
  • 'blogs'
  • 'friends'
  • 'groups'
  • 'members'
  • 'xprofile'
  • 'plugin_component'
$type
A string that describes the action type and that is used in the front-end and in the Activity Administration screens as the value of the activity dropdown filters. For instance the Activity component has two actions :

  • 'activity_update'
  • 'activity_comment'
$description
A string that describes the action description and that is used in the Activity Administration screens as the label of the activity dropdown filters. For instance the corresponding descriptions of the two action types of the Activity component are :

  • __( 'Posted a status update', 'buddypress' )
  • __( 'Replied to a status update', 'buddypress' )
$format_callback
A callable function for formatting the action string. For instance the corresponding callback functions of the two action types of the Activity component are :

  • 'bp_activity_format_activity_action_activity_update'
  • 'bp_activity_format_activity_action_activity_comment'
$label
A string that describes the action label of the activity front-end dropdown filters. For instance the corresponding labels of the two action types of the Activity component are :

  • __( 'Updates', 'buddypress' )
  • __( 'Activity Comments', 'buddypress' )
$context
An optional array that describes the Activity stream contexts where the filter should appear. Possible values are :

  • 'activity': to display the action into the dropdown filters of the Activity directory.
  • 'member': to display the action into the dropdown filters of the Member’s activity page (by default the home page).
  • 'member_groups': to display the action into the dropdown filters of the Member’s groups activity page.
  • 'group': to display the action into the dropdown filters of the group’s activity page (by default the home page).
$position
An optional integer that describes the position of the action when listed in dropdown filters. Actions are first sorted by their attached components. This argument will sort the list of actions for each component.

Top ↑

Return value Return value

Boolean: true on success, false otherwise.

Top ↑

Source File Source File

bp_activity_set_action() is located in bp-activity/bp-activity-functions.php

Top ↑

Change Log Change Log

  • 2.2.0: It will be possible to sort the activity actions within their attached component.
  • 2.1.0: Activity dropdown filters are dynamically generated instead of hardcoded into templates. See function bp_activity_show_filters()
  • 2.0.0: activity action strings are generated dynamically, rather than stored statically. This means that the data is always up-to-date for a better compatibility with multilingual sites
  • Since 1.1.0

Top ↑

Notes Notes

Since BuddyPress 2.1.0 custom templates or BuddyPress themes can use the function bp_activity_show_filters() instead of hardcoding the options into the following templates :

  • activity\index.php: use <?php bp_activity_show_filters(); ?>
  • groups\single\activity.php: use <?php bp_activity_show_filters( 'group' ); ?>
  • members\single\activity.php: use <?php bp_activity_show_filters(); ?>