Profanity filter?
Quote from Yworld on July 13, 2017, 4:57 pmHi shermtech,
function customforumcontent($content) { $censored = array( 'word 1', 'word 2', 'word 3', ); $replace = '<b>[censored]</b>'; $content = str_replace($censored, $replace, $content); return $content; } add_filter('asgarosforum_filter_post_content', 'customforumcontent');
Hi shermtech,
function customforumcontent($content) { $censored = array( 'word 1', 'word 2', 'word 3', ); $replace = '<b>[censored]</b>'; $content = str_replace($censored, $replace, $content); return $content; } add_filter('asgarosforum_filter_post_content', 'customforumcontent');
Quote from shermtech on July 13, 2017, 5:55 pmsorry to ask, but where would i insert that piece of code? Also thanks for your reply.
sorry to ask, but where would i insert that piece of code? Also thanks for your reply.
Quote from selch on February 2, 2018, 1:48 pmThanks for the code. Bu when I use this, it filters all the syllables and It’s impossible to write a proper thing. How can i prevent this?
Thanks for the code. Bu when I use this, it filters all the syllables and It’s impossible to write a proper thing. How can i prevent this?
Quote from Asgaros on February 2, 2018, 2:04 pmHello selch,
how does your code looks like?
Hello selch,
how does your code looks like?
Quote from selch on February 3, 2018, 12:00 pmHello again,
I used the same code you gave here;
- function customforumcontent($content) {
- $censored = array(
- ‘word 1’,
- ‘word 2’,
- ‘word 3’,
- );
- $replace = ‘<b>[censored]</b>’;
- $content = str_replace($censored, $replace, $content);
- return $content;
- }
- add_filter(‘asgarosforum_filter_post_content’, ‘customforumcontent’);
Hello again,
I used the same code you gave here;
- function customforumcontent($content) {
- $censored = array(
- ‘word 1’,
- ‘word 2’,
- ‘word 3’,
- );
- $replace = ‘<b>[censored]</b>’;
- $content = str_replace($censored, $replace, $content);
- return $content;
- }
- add_filter(‘asgarosforum_filter_post_content’, ‘customforumcontent’);
Quote from selch on February 3, 2018, 12:18 pmI figured it out, thank you for your help, if necessary i’m putting my version here:
function wordFilter($text) { $filter_terms = array( 'word 1', 'word 2', 'word 3'); $filtered_text = $text; foreach($filter_terms as $word) { $match_count = preg_match_all('/' . $word . '/i', $text, $matches); for($i = 0; $i < $match_count; $i++) { $bwstr = trim($matches[0][$i]); $filtered_text = preg_replace('/\b' . $bwstr . '\b/', str_repeat("*", strlen($bwstr)), $filtered_text); } } return $filtered_text; } add_filter('asgarosforum_filter_post_content', 'wordFilter');
I figured it out, thank you for your help, if necessary i’m putting my version here:
function wordFilter($text) { $filter_terms = array( 'word 1', 'word 2', 'word 3'); $filtered_text = $text; foreach($filter_terms as $word) { $match_count = preg_match_all('/' . $word . '/i', $text, $matches); for($i = 0; $i < $match_count; $i++) { $bwstr = trim($matches[0][$i]); $filtered_text = preg_replace('/\b' . $bwstr . '\b/', str_repeat("*", strlen($bwstr)), $filtered_text); } } return $filtered_text; } add_filter('asgarosforum_filter_post_content', 'wordFilter');
Quote from Asgaros on February 3, 2018, 6:01 pmI am glad to hear that you found a working solution. 🙂
I am glad to hear that you found a working solution. 🙂
Quote from Olli on March 16, 2018, 9:10 pmHello,what is the funtion of this code? Only replace words or replace links, too?RegardsOlliQuote from selch on February 3, 2018, 12:18 pmI figured it out, thank you for your help, if necessary i’m putting my version here:
function wordFilter($text) { $filter_terms = array( 'word 1', 'word 2', 'word 3'); $filtered_text = $text; foreach($filter_terms as $word) { $match_count = preg_match_all('/' . $word . '/i', $text, $matches); for($i = 0; $i < $match_count; $i++) { $bwstr = trim($matches[0][$i]); $filtered_text = preg_replace('/\b' . $bwstr . '\b/', str_repeat("*", strlen($bwstr)), $filtered_text); } } return $filtered_text; } add_filter('asgarosforum_filter_post_content', 'wordFilter');
- function wordFilter($text)
- {
- $filter_terms = array(
- ‘word 1’,
- ‘word 2’,
- ‘word 3’);
- $filtered_text = $text;
- foreach($filter_terms as $word)
- {
- $match_count = preg_match_all(‘/’ . $word . ‘/i’, $text, $matches);
- for($i = 0; $i < $match_count; $i++)
- {
- $bwstr = trim($matches[0][$i]);
- $filtered_text = preg_replace(‘/\b’ . $bwstr . ‘\b/’, str_repeat(“*”, strlen($bwstr)), $filtered_text);
- }
- }
- return $filtered_text;
- }
- add_filter(‘asgarosforum_filter_post_content’, ‘wordFilter’);
function wordFilter($text) { $filter_terms = array( 'word 1', 'word 2', 'word 3'); $filtered_text = $text; foreach($filter_terms as $word) { $match_count = preg_match_all('/' . $word . '/i', $text, $matches); for($i = 0; $i < $match_count; $i++) { $bwstr = trim($matches[0][$i]); $filtered_text = preg_replace('/\b' . $bwstr . '\b/', str_repeat("*", strlen($bwstr)), $filtered_text); } } return $filtered_text; } add_filter('asgarosforum_filter_post_content', 'wordFilter');
Hello,what is the funtion of this code? Only replace words or replace links, too?RegardsOlli
Quote from selch on February 3, 2018, 12:18 pmI figured it out, thank you for your help, if necessary i’m putting my version here:
function wordFilter($text) { $filter_terms = array( 'word 1', 'word 2', 'word 3'); $filtered_text = $text; foreach($filter_terms as $word) { $match_count = preg_match_all('/' . $word . '/i', $text, $matches); for($i = 0; $i < $match_count; $i++) { $bwstr = trim($matches[0][$i]); $filtered_text = preg_replace('/\b' . $bwstr . '\b/', str_repeat("*", strlen($bwstr)), $filtered_text); } } return $filtered_text; } add_filter('asgarosforum_filter_post_content', 'wordFilter');
- function wordFilter($text)
- {
- $filter_terms = array(
- ‘word 1’,
- ‘word 2’,
- ‘word 3’);
- $filtered_text = $text;
- foreach($filter_terms as $word)
- {
- $match_count = preg_match_all(‘/’ . $word . ‘/i’, $text, $matches);
- for($i = 0; $i < $match_count; $i++)
- {
- $bwstr = trim($matches[0][$i]);
- $filtered_text = preg_replace(‘/\b’ . $bwstr . ‘\b/’, str_repeat(“*”, strlen($bwstr)), $filtered_text);
- }
- }
- return $filtered_text;
- }
- add_filter(‘asgarosforum_filter_post_content’, ‘wordFilter’);
function wordFilter($text) { $filter_terms = array( 'word 1', 'word 2', 'word 3'); $filtered_text = $text; foreach($filter_terms as $word) { $match_count = preg_match_all('/' . $word . '/i', $text, $matches); for($i = 0; $i < $match_count; $i++) { $bwstr = trim($matches[0][$i]); $filtered_text = preg_replace('/\b' . $bwstr . '\b/', str_repeat("*", strlen($bwstr)), $filtered_text); } } return $filtered_text; } add_filter('asgarosforum_filter_post_content', 'wordFilter');