Add this to your functions file
add_filter( 'bbp_get_reply_content', 'rew_remove_code_tags', 10, 2 );
function rew_remove_code_tags ($content, $reply_id) {
if (!is_user_logged_in()) {
$content = preg_replace("/<code>.+?<\/code>/i", "", $content);
}
return apply_filters( 'rew_remove_code_tags', $content, $reply_id );
}
Thanks, but it work only if text between code is on one row. If someune post log test separated by rows, then didnt work properly.
Any idea how to fix ?
Ok i find a solution i just change flag /i for flag /s
$content = preg_replace("/<code>.+?<\/code>/S", "", $content);
But i have a question it is correct solution? No performace issue ?
this does that
add_filter( 'bbp_get_reply_content', 'rew_remove_code_tags', 10, 2 );
function rew_remove_code_tags ($content, $reply_id) {
if (!is_user_logged_in()) {
$content = preg_replace('~<code(.*?)</code>~Usi', "", $content);
}
return apply_filters( 'rew_remove_code_tags', $content, $reply_id );
}
But i have a question it is correct solution? No performace issue ?
yes it has a performance issue, every line of code has a performance issue.
No idea by what you mean ‘is it the correct solution’ This is a help service for bbpress not a free bespoke website service. I have already gone beyond the usual to help you.
It is up to you to decide the balance of SEO against performance, not me.