Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding friendship link to activity feed

  • I have managed to add the friendship link to each activity post that is friendable. I wasn’t able to do this with a custom theme, since I wanted it in the activity header (beside the “View” link), and so I had to hard code it into the `bp-activity/bp-activity-templatetags.php` file. Here’s the code, which goes in the `bp_insert_activity_meta` function after the delete button:

    ` /* Add friendship link */
    if ( is_user_logged_in() && $activities_template->activity->user_id != $bp->loggedin_user->id ) {
    global $bp, $friends_template;

    if ( empty( $potential_friend_id ) )
    $potential_friend_id = $activities_template->activity->user_id;

    $is_friend = bp_is_friend( $potential_friend_id );

    if ( empty( $is_friend ) )
    break;

    switch ( $is_friend ) {
    case ‘pending’ :
    $url = trailingslashit( $bp->loggedin_user->domain . $bp->friends->slug );
    $title = ‘Friendship Requested’;
    break;
    case ‘is_friend’ :
    $url = wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . ‘/remove-friend/’ . $potential_friend_id . ‘/’, ‘friends_remove_friend’ );
    $title = ‘Cancel Friendship’;
    break;
    default:
    $url = wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . ‘/add-friend/’ . $potential_friend_id . ‘/’, ‘friends_add_friend’ );
    $title = ‘Add Friend’;
    break;
    }
    $content .= ‘ ยท ‘.$title.’‘;
    }`

  • The topic ‘Adding friendship link to activity feed’ is closed to new replies.
Skip to toolbar