AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

[Solved] Need a way to strip html tags from posts before saved

3 Posts
2 Users
2 Reactions
1,615 Views
Posts: 2
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@nomadic)
New Member
Joined: 3 years ago
[#50009]

Is there any filter to do this? I have searched the forums and the answer has been "we allow all safe html tags". But in my case, I really need users to only write in textarea style, meaning p and br tags only. 
How can I achieve this? 


2 Replies
BlackRaz
Posts: 396
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@blackraz)
Contributor
Joined: 9 years ago

"Hi @nomadic,

Yes, wpForo has filter hooks for changing the allowed HTML tags for posts.
Here is our filter for allowed HTML tags. You can add your custom function to our filter hook to manipulate the allowed HTML tags."

$allowed_html = apply_filters( 'wpforo_kses_allowed_html', $allowed_html );

 


Posts: 2
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@nomadic)
New Member
Joined: 3 years ago

Seems to be working, thank you! 
Here is a working example, in case someone else needs the same:

function custom_wpforo_kses_allowed_html($allowed_html) 
{    
    $allowed_html = array(
        'strong' => array(),
        'br' => array(),
        'b' => array(),
        'a' => array(
            'href' => array(),
            'title' => array(),
        ),
        'blockquote' => array(
            'class' => array(),
            'data-width' => array(),
            'data-userid' => array(), 
            'data-postid' => array(), 
        ),
        'p' => array(),
    );

    return $allowed_html;
}
add_filter('wpforo_kses_allowed_html', 'custom_wpforo_kses_allowed_html');

Share: