bp_friends_clear_bp_friends_friendships_cache( int $friendship_id, int $initiator_user_id, int $friend_user_id )
Clear friendship caches on friendship changes.
Description
Parameters
- $friendship_id
-
(Required) ID of the friendship that has changed.
- $initiator_user_id
-
(Required) ID of the first user.
- $friend_user_id
-
(Required) ID of the second user.
Return
(bool)
Source
File: bp-friends/bp-friends-cache.php
function bp_friends_clear_bp_friends_friendships_cache( $friendship_id, $initiator_user_id, $friend_user_id ) {
// Clear friendship ID cache for each user.
wp_cache_delete( $initiator_user_id, 'bp_friends_friendships_for_user' );
wp_cache_delete( $friend_user_id, 'bp_friends_friendships_for_user' );
// Clear the friendship object cache.
wp_cache_delete( $friendship_id, 'bp_friends_friendships' );
// Clear incremented cache.
$friendship = new stdClass;
$friendship->initiator_user_id = $initiator_user_id;
$friendship->friend_user_id = $friend_user_id;
bp_friends_delete_cached_friendships_on_friendship_save( $friendship );
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.7.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.