• Resolved memark1955

    (@memark1955)


    Hello Site Reviews Support Team,

    As a class assignment I am developing a WordPress plugin designed to filter out specific objectionable words from user-generated content. My plugin aims to apply these filters dynamically to review content displayed on webpages by the Site Reviews plugin, replacing identified words with a placeholder (e.g., “******”) before the content is rendered to the user. Importantly, this filtering should occur without altering the original review content stored in the database.

    Could you please advise on the correct hook or filter I should use to intercept and modify review text content before it is displayed on the webpage? I am specifically looking for a way to apply my objectionable word filters to both the review body and any other user-submitted text fields associated with reviews (such as the reviewer’s name), ensuring these modifications are made just-in-time during page rendering.

    Additionally, if there are any particular considerations or best practices when using the recommended hook(s) for this purpose, I would greatly appreciate your insights.

    Thank you very much for your assistance.

    Best regards,

    Mark

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    There are a few different ways in which you can do this. The two simplest ways are probably going to be this:

    add_action('site-reviews/get/review', function (\GeminiLabs\SiteReviews\Review $review): void {
        $content = $review->content;
        // modify $content here...
        $review->set('content', $content);
    });

    Or this:

    add_filter('site-reviews/review/value/content', function (string $value): string {
        // modify $value here...
        return $value;
    });

    Keep in mind the string value in the second method may contain HTML tags depending on the tag value being filtered.

    FYI: Site Reviews provides a blacklist option which essentially already does this when the review is submitted but before it is saved.

    Thread Starter memark1955

    (@memark1955)

    Thank you that worked great. I really appreciate your assistance.

    Can you suggest what I would use to filter post_title and the name column in wp_3e2hm4_glsr_ratings? I tried several things and did refer to your Actions and Filters page at GitHub but couldnt find anything that works, but I am a newbie to programming.

    I know it would be a lot easier to use your blacklist feature, but as I mentioned its a class assignment.

    Thanks again,

    Mark

    Plugin Author Gemini Labs

    (@geminilabs)

    $name = $review->author;
    $title = $review->title;
    // ...
    $review->set('author', $name);
    $review->set('title', $title);

    Or use the “site-reviews/review/value/author” and “site-reviews/review/value/title” hooks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Filtering for Objectionable Words’ is closed to new replies.