Thanks @vapvarun
Should this be added to functions.php or bp-custom.php? Or somewhere else?
Thanks again
@mjhpersonnel better to use code snippet plugin, it’s easy to manage
Thanks both. This works perfect and links in the activity section now open in a new page. Top stuff. π
Hi
I pasted https://pastebin.com/Z3z7s87j into a code snippet and it does nothing WP 5.7.1 β I set it to Run Snippet Everywhere.
Not sure why this would not be standard option in Buddypress. In seconds all my users are off and outside my site which they donβt want to be! They want to stay on it β not have to keep finding the URL to my social network.
Any ideas how to do this in activity stream?
Thanks.
@epgb101 try to use raw code inside code snippet plugin
// open all buddypress activity links in new tab
function vap_activity_links_target_blank($link) {
$link = str_replace(' rel="nofollow ugc"','target="_blank" rel="nofollow ugc"',$link);
return $link;
}
add_filter('bp_get_activity_content','vap_activity_links_target_blank',20);
add_filter('bp_get_activity_content_body','vap_activity_links_target_blank',20);
add_filter('bp_get_activity_parent_content','vap_activity_links_target_blank',20);
add_filter('bp_get_activity_latest_update','vap_activity_links_target_blank',20);
add_filter('bp_get_activity_latest_update_excerpt','vap_activity_links_target_blank',20);
add_filter('bp_get_activity_feed_item_description','vap_activity_links_target_blank',20);
add_filter('bp_get_activity_feed_item_description','vap_activity_links_target_blank',20);
I can’t believe it – it worked! – what is ‘raw code’ as opposed to what I copied/pasted before?
I searched for this for a whole day and found nothing useful surely more people need this.
Thank you very much. π
Glad you got it sorted, I think the reason this isn’t more widely used is due to accessibility, the w3 advises against using a new window except for certain circumstance to avoid a negative impact on those with accessibility needs.
I see – I did not know that – thank you for letting me know.