How to allow target = “_blank” HTML in BuddyPress forum topic replies

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  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.

Posted in ,

The Mighty Mo! Design Co.

More posts from themightymo.com

How to merge two folders, including all sub-folders and files, on Mac

By The Mighty Mo! Design Co. | November 3, 2022

Today I had an issue where I needed to merge two folders, each of which contained many sub- and sub-sub folders that had lots of images. After a lot of trial-and-error and some Googling, I found the best solution is to use the “ditto” command in Terminal like this: That’s it! Hat tip to AppleInsider.

mailchimp usage stats

Some Surprising Trends in Website Development

By Toby Cryns | October 17, 2022

I wasted some time today to bring you (dum dum duuuuum!): Some Surprising Trends in Website Development!

How to Configure WordPress with Cloudflare, HSTS, TLS, and Secure Headers

By The Mighty Mo! Design Co. | October 11, 2022

I was recently asked to look into creating some secure http headers as well as forcing a website to load over TLS1.2+. Below are my “how to” instructions for updating these settings within WordPress and Cloudflare. Install & Configure the Cloudflare WordPress plugin. Make sure an SSL Certificate is installed on your host for your…