bp_friends_format_activity_action_friendship_created

Format 'friendship_created' activity actions.

Description

(string) bp_friends_format_activity_action_friendship_created( (string) $action, (object) $activity ); 

Returns (string)

$action Formatted activity action.

Parameters (2)

0. $action (string)
Static activity action.
1. $activity (object)
Activity data.

Usage

  1. if ( !function_exists( 'bp_friends_format_activity_action_friendship_created' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-friends/bp-friends-activity.php'; 
  3.  
  4. // Static activity action. 
  5. $action = ''; 
  6.  
  7. // Activity data. 
  8. $activity = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_friends_format_activity_action_friendship_created($action, $activity); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-friends/bp-friends-activity.php  
  1. function bp_friends_format_activity_action_friendship_created( $action, $activity ) { 
  2. $initiator_link = bp_core_get_userlink( $activity->user_id ); 
  3. $friend_link = bp_core_get_userlink( $activity->secondary_item_id ); 
  4.  
  5. $action = sprintf( __( '%1$s and %2$s are now friends', buddypress ), $initiator_link, $friend_link ); 
  6.  
  7. // Backward compatibility for legacy filter 
  8. // The old filter has the $friendship object passed to it. We want to 
  9. // avoid having to build this object if it's not necessary. 
  10. if ( has_filter( 'friends_activity_friendship_accepted_action' ) ) { 
  11. $friendship = new BP_Friends_Friendship( $activity->item_id ); 
  12. $action = apply_filters( 'friends_activity_friendsip_accepted_action', $action, $friendship ); 
  13.  
  14. /** 
  15. * Filters the 'friendship_created' activity action format. 
  16. * @since 2.0.0 
  17. * @param string $action String text for the 'friendship_created' action. 
  18. * @param object $activity Activity data. 
  19. */