bp_activity_adjust_mention_count( int $activity_id, string $action = 'add' )
Adjusts mention count for mentioned users in activity items.
Description Description
This function is useful if you only have the activity ID handy and you haven’t parsed an activity item for @mentions yet.
Currently, only used in bp_activity_delete().
Parameters Parameters
- $activity_id
-
(Required) The unique id for the activity item.
- $action
-
(Optional) Can be 'delete' or 'add'. Defaults to 'add'.
Default value: 'add'
Return Return
(bool)
Source Source
File: bp-activity/bp-activity-functions.php
function bp_activity_adjust_mention_count( $activity_id = 0, $action = 'add' ) { // Bail if no activity ID passed. if ( empty( $activity_id ) ) { return false; } // Get activity object. $activity = new BP_Activity_Activity( $activity_id ); // Try to find mentions. $usernames = bp_activity_find_mentions( strip_tags( $activity->content ) ); // Still empty? Stop now. if ( empty( $usernames ) ) { return false; } // Increment mention count foreach mentioned user. foreach( (array) array_keys( $usernames ) as $user_id ) { bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action ); } }
Changelog Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |