Skip to:
Content
Pages
Categories
Search
Top
Bottom

How can I disable HTML in posts?


  • Burakhan
    Member

    @burakhan

    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?

Viewing 3 replies - 1 through 3 (of 3 total)

  • chrishajer
    Participant

    @chrishajer

    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.


    Burakhan
    Member

    @burakhan

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


    jonich0n
    Member

    @jonich0n

    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);

    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);

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.