BuddyPress Activity Links Open in a New Tab

Not necessarily best practice but here’s the code to filter the BuddyPress activity feed and add target=”_blank” to all the links.

//BUDDYPRESS ACTIVITY FILTER 

function altlab_special_links_activity( $body ) { 
     $body = str_replace(' rel="nofollow"',' rel="nofollow" target="_blank"',$body);

    return $body; 

}
add_filter( 'bp_get_activity_content_body', 'altlab_special_links_activity', 15, 1 );