Support » Plugin: bbp style pack » HTML getting posted in New Topic form

  • Resolved David Wang

    (@blogjunkie)


    Hi there, we frequently get HTML posted in the new topic forms. The forms are set to show both visual and text editors, enabled by bbP Style Pack. Here is a sample of the content we received:

    <div dir="ltr" data-setdir="false">I think I can add to this</div>
    <div dir="ltr" data-setdir="false"></div>
    <div dir="ltr" data-setdir="false">A friend of mine does the occasional dog minding at his flat and has been doing so for 3 years. He does not run a business, but gets the bookings through an agency, a totally different thing</div>
    <div dir="ltr" data-setdir="false"></div>
    <div dir="ltr" data-setdir="false">The home pet minding regulations in Vic are very clear.</div>
    <div dir="ltr" data-setdir="false"></div>
    <div dir="ltr" data-setdir="false">It is necessary to talk to the Council about this first so that they can come out to inspect the flat , and also for the minder to pay for a multi dog permit if there should be more than one dog.Also the policy of the OC needs to be pet friendly, which it is where he lives and many own pets in his block. . He has done all this and has full compliance.</div>
    <div dir="ltr" data-setdir="false"></div>
    <div dir="ltr" data-setdir="false">He is meticulous about the dog he will mind and meets them first to ensure that they are quiet and friendly. Most of his neighbours enjoy meeting them except for one who is an animal hater (and people hater for that matter :-) ) but he is always outvoted.</div>
    <div dir="ltr" data-setdir="false"></div>
    <div dir="ltr" data-setdir="false">btw insurance is partly the responsibility of the agency and the minder only.</div>
    <div dir="ltr" data-setdir="false"></div>
    <div dir="ltr" data-setdir="false">Hope this clarifies things a bit. . .</div>
    <div dir="ltr" data-setdir="false"></div>
    <div dir="ltr" data-setdir="false">.</div>

    What can we do to strip out the HTML from the form submissions?

    • This topic was modified 2 months, 3 weeks ago by  David Wang.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Robin W

    (@robin-w)

    Put this in your child theme’s function file – or use
    https://en-gb.wordpress.org/plugins/code-snippets/

    add_filter ('bbp_new_topic_pre_content' , 'rew_new_strip_tags' ) ;
    
    function rew_new_strip_tags ($topic_content) {
    $topic_content =  strip_tags ($topic_content) ;
    return $topic_content ;
    }
    
    add_filter ('bbp_edit_topic_pre_content' , 'rew_edit_strip_tags', 10, 2 ) ;
    
    function rew_edit_strip_tags ($topic_content, $topic_id) {
    $topic_content =  strip_tags ($topic_content) ;
    return $topic_content ;
    }

    Thanks Robin, but won’t this strip all tags? I want to keep bold, italics, links – all the formatting enabled by bbp style pack’s rich editor. Thank you

    Plugin Author Robin W

    (@robin-w)

    I was answering the question asked 🙂

    If you want to allow some then change

    strip_tags ($topic_content)

    to

    strip_tags ($topic_content, '<b><i>')

    in each section

    and add any others that you want to that

    Thank you, I should have been more specific with my questions then. Cheers

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.