| package | BuddyPress |
|---|
__construct(integer|boolean $id = false)
| since | 1.5.0 |
|---|
integerbooleanOptional. The ID of a specific activity item.
check_exists_by_content(string $content) : integer | false
| since | 1.1.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
stringThe content to filter by.
integerfalseThe ID of the first matching item if found, otherwise false.delete(array $args = array()) : array | boolean
To delete a specific activity item, pass an 'id' parameter. Otherwise use the filters.
| since | 1.2.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
array{ @int $id Optional. The ID of a specific item to delete. @string $action Optional. The action to filter by. @string $content Optional. The content to filter by. @string $component Optional. The component name to filter by. @string $type Optional. The activity type to filter by. @string $primary_link Optional. The primary URL to filter by. @int $user_id Optional. The user ID to filter by. @int $item_id Optional. The associated item ID to filter by. @int $secondary_item_id Optional. The secondary associated item ID to filter by. @string $date_recorded Optional. The date to filter by. @int $hide_sitewide Optional. Default: false. }
arraybooleanAn array of deleted activity IDs on success, false on failure.delete_activity_item_comments(array $activity_ids= array(), boolean $delete_meta= true) : boolean
This method is no longer used by BuddyPress, and it is recommended not to use it going forward, and use BP_Activity_Activity::delete() instead.
| since | 1.2.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
| deprecated | 2.3.0 |
arrayActivity IDs whose comments should be deleted.
booleanShould we delete the activity meta items for these comments.
booleanfind_comment_in_tree(array $comments, integer $target_id) : object | false
| since | 14.5.0 |
|---|
arrayArray of comment objects with nested children.
integerThe comment ID to find.
objectfalseThe comment object if found, false otherwise.get(array $args = array()) : array
| since | 1.2.0 |
|---|---|
| since | 2.4.0 Introduced the `$fields` parameter. |
| since | 2.9.0 Introduced the `$order_by` parameter. |
| since | 10.0.0 Introduced the `$count_total_only` parameter. |
| since | 11.0.0 Introduced the `$user_id__in` and `$user_id__not_in` parameters. |
| see | for a description of the 'filter' parameter. |
| see | for a description of the 'meta_query' parameter format. |
| global | wpdb $wpdb WordPress database object. |
array{ An array of arguments. All items are optional. @type int $page Which page of results to fetch. Using page=1 without per_page will result in no pagination. Default: 1. @type int|bool $per_page Number of results per page. Default: 25. @type int|bool $max Maximum number of results to return. Default: false (unlimited). @type string $fields Activity fields to return. Pass 'ids' to get only the activity IDs. 'all' returns full activity objects. @type string $sort ASC or DESC. Default: 'DESC'. @type string $order_by Column to order results by. @type array $exclude Array of activity IDs to exclude. Default: false. @type array $in Array of ids to limit query by (IN). Default: false. @type array $meta_query Array of meta_query conditions. See WP_Meta_Query::queries. @type array $date_query Array of date_query conditions. See first parameter of WP_Date_Query::construct(). @type array $filter_query Array of advanced query conditions. See BP_Activity_Query::__construct(). @type string|array $scope Pre-determined set of activity arguments. @type array $filter See BP_Activity_Activity::get_filter_sql(). @type array $user_idin An array of user ids to include. Activity posted by users matching one of these user ids will be included in results. Default empty array. @type array $user_id__not_in An array of user ids to exclude. Activity posted by users matching one of these user ids will not be included in results. Default empty array. @type string $search_terms Limit results by a search term. Default: false. @type bool $display_comments Whether to include activity comments. Default: false. @type bool $show_hidden Whether to show items marked hide_sitewide. Default: false. @type string $spam Spam status. Default: 'ham_only'. @type bool $cache_results Optional. Whether to cache activity information. Default true. @type bool $update_meta_cache Whether to pre-fetch metadata for queried activity items. Default: true. @type string|bool $count_total If true, an additional DB query is run to count the total activity items for the query. Default: false. @type bool $count_total_only If true, only the DB query to count the total activity items is run. Default: false. }
arrayThe array returned has two keys:
- 'total' is the count of located activities
- 'activities' is an array of the located activitiesget_activity_comments(integer $activity_id, integer $left, integer $right, string $spam= 'ham_only', integer $top_level_parent_id= 0) : array
| since | 1.2.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
integerActivity ID to fetch comments for.
integerLeft-most node boundary.
integerRight-most node boundary.
stringOptional. 'ham_only' (default), 'spam_only' or 'all'.
integerOptional. The id of the root-level parent activity item.
arrayThe updated activities with nested comments.get_child_comments(integer $parent_id) : object
| since | 1.2.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
integerID of an activity or activity comment.
objectNumerically indexed array of child comments.get_date_query_sql(array $date_query = array()) : string
We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting of parsing the date_query array and creating the necessary SQL clauses.
| since | 2.1.0 |
|---|
arrayAn array of date_query parameters. See the documentation for the first parameter of WP_Date_Query.
stringget_filter_sql(array $filter_array) : string
| since | 1.5.0 |
|---|
array{ Fields and values to filter by.
@type array|string|int $user_id User ID(s).
@type array|string $object Corresponds to the 'component'
column in the database.
@type array|string $action Corresponds to the 'type' column
in the database.
@type array|string|int $primary_id Corresponds to the 'item_id'
column in the database.
@type array|string|int $secondary_id Corresponds to the
'secondary_item_id' column in the database.
@type int $offset Return only those items with an ID greater
than the offset value.
@type int $offset_lower Return only those items with an ID lower
than the offset value.
@type string $since Return only those items that have a
date_recorded value greater than a
given MySQL-formatted date.
}
stringThe filter clause, for use in a SQL query.get_id(array $args = array()) : integer | false
| since | 1.2.0 |
|---|---|
| since | 10.0.0 Parameters were made optional. |
| global | wpdb $wpdb WordPress database object. |
array{ An array of arguments. All items are optional. @type int $user_id User ID to filter by. @type string $component Component to filter by. @type string $type Activity type to filter by. @type int $item_id Associated item to filter by. @type int $secondary_item_id Secondary associated item to filter by. @type string $action Action to filter by. @type string $content Content to filter by. @type string $date_recorded Date to filter by. }
integerfalseActivity ID on success, false if none is found.get_in_operator_sql(string $field, array|boolean $items) : string | false
get_last_updated() : string
| since | 1.2.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
stringISO timestamp.get_recorded_components(boolean $skip_last_activity = true) : array
| since | 1.2.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
booleanIf true, components will not be included if the only activity type associated with them is 'last_activity'. (Since 2.0.0, 'last_activity' is stored in the activity table, but these items are not full-fledged activity items.) Default: true.
arrayList of component names.get_scope_query_sql(mixed $scope= false, array $r= array()) : false | array
A scope is a predetermined set of activity arguments. This method is used to grab these activity arguments and override any existing args if needed.
Can handle multiple scopes.
| since | 2.2.0 |
|---|
mixedThe activity scope. Accepts string or array of scopes.
arrayCurrent activity arguments. Same as those of BP_Activity_Activity::get(), but merged with defaults.
falsearray'sql' WHERE SQL string and 'override' activity args.get_sitewide_items_for_feed(integer $limit = 35) : array
| since | 1.0.0 |
|---|
integerOptional. Number of items to fetch. Default: 35.
array$activity_feed List of activity items, with RSS data added.get_specific(mixed $activity_ids, integer|boolean $max= false, integer $page= 1, integer $per_page= 25, string $sort= 'DESC', boolean $display_comments= false) : array
As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
| since | 1.2.0 |
|---|---|
| deprecated | 1.5 |
| deprecated | Use BP_Activity_Activity::get() with an 'in' parameter instead. |
mixedArray or comma-separated string of activity IDs to retrieve.
integerbooleanMaximum number of results to return. (Optional; default is no maximum).
integerThe set of results that the user is viewing. Used in pagination. (Optional; default is 1).
integerSpecifies how many results per page. Used in pagination. (Optional; default is 25).
stringMySQL column sort; ASC or DESC. (Optional; default is DESC).
booleanRetrieve an activity item's associated comments or not. (Optional; default is false).
arrayhide_all_for_user(integer $user_id) : mixed
| since | 1.2.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
integerThe ID of the user whose activity you want to mark hidden.
mixedpopulate()
| since | 1.0.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
rebuild_activity_comment_tree(integer $parent_id, integer $left = 1) : integer
| since | 1.2.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
integerID of an activity or activity comment.
integerNode boundary start for activity or activity comment.
integerRight Node boundary of activity or activity comment.save() : \WP_Error | boolean
| since | 1.0.0 |
|---|---|
| global | wpdb $wpdb WordPress database object. |
\WP_ErrorbooleanTrue on success.total_favorite_count(integer $user_id) : integer
| since | 1.2.0 |
|---|
integerThe ID of the user whose favorites you're counting.
integer$value A count of the user's favorites.append_user_fullnames(array $activities) : array
| since | 2.0.0 |
|---|
arrayActivities array.
arraygenerate_action_strings(array $activities) : array
If no string can be dynamically generated for a given item (typically because the activity type has not been properly registered), the static 'action' value pulled from the database will be left in place.
| since | 2.0.0 |
|---|
arrayArray of activities.
arrayget_activity_data(array $activity_ids= array(), boolean $cache_results= true) : array
| since | 2.0.0 |
|---|---|
| since | 15.0.0 Added the `$cache_results` parameter. |
| global | wpdb $wpdb WordPress database object. |
arrayArray of activity IDs.
booleanOptional. Whether to cache activity information. Default true.
arrayprefetch_object_data(array $activities) : array
Activity items are associated with users, and often with other BuddyPress data objects. Here, we pre-fetch data about these associated objects, so that inline lookups - done primarily when building action strings - do not result in excess database queries.
The only object data required for activity component activity types (activity_update and activity_comment) is related to users, and that info is fetched separately in BP_Activity_Activity::get_activity_data(). So this method contains nothing but a filter that allows other components, such as bp-friends and bp-groups, to hook in and prime their own caches at the beginning of an activity loop.
| since | 2.0.0 |
|---|
arrayArray of activities.
array$activities Array of activities.$action : string
''| since | 1.2.0 |
|---|
$component : string
''| since | 1.2.0 |
|---|
$content : string
''| since | 1.2.0 |
|---|
$date_recorded : string
''| since | 1.0.0 |
|---|
$error_type : string
'bool'| since | 2.6.0 |
|---|
$errors : \WP_Error
| since | 2.6.0 |
|---|
$hide_sitewide : integer
0| since | 1.1.0 |
|---|
$id : integer
| since | 1.0.0 |
|---|
$is_spam : integer
| since | 1.6.0 |
|---|
$item_id : integer
| since | 1.0.0 |
|---|
$mptt_left : integer
| since | 1.5.0 |
|---|
$mptt_right : integer
| since | 1.5.0 |
|---|
$primary_link : string
''| since | 1.0.0 |
|---|
$secondary_item_id : integer
| since | 1.0.0 |
|---|
$type : string
''| since | 1.2.0 |
|---|
$user_id : integer
| since | 1.0.0 |
|---|
Append activity comments to their associated activity items.
Parameters
$activities
arrayActivities to fetch comments for.
$spam
stringOptional. 'ham_only' (default), 'spam_only' or 'all'.
Returns
arrayThe updated activities with nested comments.