Skip to:
Content
Pages
Categories
Search
Top
Bottom

C*nsor posts but not in specific category

  • I am using the C*nsor posts plugin on bbPress 1.0.1, works perfectly…

    However, I want to disable the censor on one forum.

    the function used in the plugin is:

    function censor_post_text($post) {

    if (!bb_get_option('censor_enable')) {return $post;}
    $words = bb_get_option('censor_words');
    if ($words[0]=='') return $post;
    foreach ($words as $key => $word) {
    $words[$key] = '/b('.preg_quote($word).')b/i';
    }
    $replace = array();
    $numwords = sizeof($words);
    for($i = 0; $i < $numwords; $i++) {
    array_push($replace, "****");
    }
    $clean_post = preg_replace($words, $replace, $post);
    return $clean_post;

    }

    anyone know how I would add something like – if not in form id 20 – to the above?

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

  • _ck_
    Participant

    @_ck_

    The problem is the way the plugin is written, the same filter is used for the title and such.

    the post_text filter can also pass the post_id which you can use to lookup the forum the post is in but you’d have to modify more of the plugin to not use the post_id

    you can try modifying this

    add_filter('post_text', 'censor_post_text');

    to

    add_filter('post_text', 'censor_post_text',10,2);

    so it then passes the post_id

    Then change this

    function censor_post_text($post) {

    to this

    function censor_post_text($post,$post_id=0) {

    and then add this after the above

    if (!empty($post_id)) {$temp=bb_get_post($post_id); if ($temp->forum_id==20) {return $post;}}

    thanks _ck_ works perfectly…

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