Forums

Join
bbPress Support ForumsTroubleshootingHow can I disable HTML in posts?

Info

How can I disable HTML in posts?

  1. Hi everyone,
    I want to disable HTML codes in posts. I am using "BBcode Lite for bbPress" and I dont need html codes to edit my post. When my member want to add a HTML code that is useful to forums the code works and havent seen properly. How can I disable?

  2. The allowable HTML tags are in an array called bb_allowed_tags. I think you could create a plugin that just empties that array.

    http://bbpress.org/forums/topic/hooks-038-filters-docu#post-6740

    I've only seen people requesting the opposite, allowing additional HTML markup, so I'm not sure exactly how to do this.

  3. Thanks for your help. I tried but I couldnt do it. Any other ideas?

  4. The function you're looking for is bb_allowed_tags in functions.bb-formatting.php, and the allowed tags are stored in an array called $tags.

    Create your own plugin file in /my-plugins/, activate it, and apply code to remove (unset) the desired HTML tags from the array. Or just empty the array completely (although I haven't tested this). Below is an example where I removed anchor/hyperlink functionality in posts:


    function remove_a_in_allowed_tags( $tags ) {
    unset($tags['a']);
    return $tags;
    }
    add_filter( 'bb_allowed_tags', 'remove_a_in_allowed_tags' );

    You can quickly test this by inspecting the $tags array with the following code:


    // test allowed tags
    $tags = bb_allowed_tags();
    print_r($tags);

  5. This topic is closed