Enable or Disable All HTML Tags in WordPress Author Biography Profiles
By default, WordPress strips some (but not all) HTML tags. You’re able to type all the HTML you want into the About Yourself –> Biographical Info text box for each WordPress profile, but HTML tags like p (new paragraph) and br (line break) get stripped once you click to save.
Because of this, longer bios look like one big, chunky paragraph instead of being split into several cleaner-looking paragraphs.
Enable all HTML Tags in Profile Bios
To disable the default WordPress HTML tag “sanitization”, you can add this snippet to your theme’s functions.php file or in your own separate plugin:
{code type=php}//disable WordPress sanitization to allow more than just $allowedtags from /wp-includes/kses.php
remove_filter(‘pre_user_description’, ‘wp_filter_kses’);
//add sanitization for WordPress posts
add_filter( ‘pre_user_description’, ‘wp_filter_post_kses’);
After activating this snippet, the author bios can include p, br, and other HTML tags. It can also be useful for adding rel=”author” to each biography box’s Google Plus link as an alternative way to Add Google Plus Authorship to your WordPress Site:
{code type=php}<a href=”https://plus.google.com/yourIDhere” rel=”author”>Your Google Profile</a>
Warning
WordPress sanitizes user input for security reasons, not just to annoy you and make you go on a hunt to find this post to learn how to override the annoying setting.
If you’re considering disabling the WordPress sanitization, make sure you trust your users to not enter potentially harmful content into their profile bios. This includes iframes, forms, and more.
Disable all HTML in Profile Bios
If you want the opposite, disallowing all HTML (including the a, blockquote, em, and strong tags, to name a few), you can use the following snippet:
{code type=php}//disallow all HTML tags
add_filter( ‘pre_user_description’, ‘wp_filter_nohtml_kses’);
Examples
Here is a list of screenshots for you to compare and contrast. Each image has a descriptive caption and each can be clicked for a larger view.
References
- List of WordPress default allowed HTML tags: 3.4.2’s wp-includes/kses.php line number 439 (i.e. what’s allowed without using either one of the above two snippets)
- The wp_filter_post_kses function
- The wp_filter_kses function
Credit: html tattoo image