Today, I had the challenge of allowing users to use the target=”_blank” html attribute in BuddyPress forum topic replies. By default, BuddyPress will ignore any target attributes you add to your links.

The secret fix is to tell BuddyPress that you want to allow the target attribute by adding the following code to your functions.php file:

/* Add the HTML <a> tag attribute 'target' to the list
 * of allowed tags & attributes in BP's activity filters.
function ufmn_add_target_attribute( $activity_allowedtags ) {
	$activity_allowedtags['a']['target']    = array();
	return $activity_allowedtags;
add_filter( 'bp_activity_allowed_tags', 'ufmn_add_target_attribute', 1 );
add_filter( 'bp_forums_allowed_tags', 'ufmn_add_target_attribute', 1 );

Pretty neat, eh?!

CREDIT: Literally ALL of the credit for the above solution goes to Dave Ellenwood over at DPE Design.


We love to communicate: phone, email, text, Facebook, Twitter, LinkedIn, you name it.



Call Now

Enroll in Our Free Beginner WordPress Class - delivered to your Email Inbox!

Become a WordPress superstar for FREE in only minutes a day!  Our free Beginner WordPress Email Class will be delivered to your inbox!

Learn More 

You Have Successfully Enrolled! Prepare For Amazing!