I want to automatically remove any kind of links from author's Biographical Info instead of doing it manually everytime. Whenever a user adds any link to the Biographical Info box, it should be automatically striped off when it's viewed on the blog.


You can use pre_user_description hook, which filters the user's description prior to saving/updating the user, to remove any unwanted tags.

To do that, you can use the wp_kses function, which strips out all but whitelisted tags.

The allowed tags should be given as an associative array, where the keys are the names of the tags, and the values are an array of allowed attributes for this tag.

For example to allow only <strong> and <em> tags (without any attributes) and the <h1> tag (with possibly the class attribute only):

function wpse_whitelist_tags_in_bio($description){
    $bio_allowed_tags = array(
                         'h1' => array(
                            'class' => array (),

    $description = wp_kses($description,$bio_allowed_tags);
    return $description;

wp_kses is an expensive function, so it should only be run when data is saved, not displayed. To strip out all HTML tags, you can use wp_strip_all_tags()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.