Zhongde Liu

This is my personal "Clipboard" of web development stuff I come across


Leave a comment

Allowing HTML in WordPress user profile description

One of my latest tasks was to create a fancy author page in a WordPress powered blog. So I thought, let the authors fill out there description field in the admin backend and pull the data out for display on the author page. To put themselves under the right light some of the authors used hmtl-formatted texts to describe them. Good idea!

Unfortunately WordPress has a filter, which strips nearly all of the html-tags used in the description text. So the result was pretty ugly ….

After some research, how others solve this issue, I was shocked that hacking the core – tipps were the top google hits (e.g. here or here) . Just an advice independent from this issue. “Don’t hack the core !” You maybe will regret this later ….

As I mentioned there is a filter which strips out the html-tags. So there is the handy function called remove_filter() in wordpress. You just have to identify the one you have to remove…

All in all here is the solution instead of hacking the core, just add this line somewhere in your php code (preferably functions.php):

remove_filter('pre_user_description', 'wp_filter_kses');

And there you go, no html is stripped from the input text. But be careful, you should trust your users. Because this filter has a reason 😉