WordPress.org

Ready to get started?Download WordPress

Forums

Catching Certain Comments before they save (6 posts)

  1. gariusthebrit
    Member
    Posted 2 years ago #

    On a site I run, we have a relatively self-policing, open (but spam-filtered) commenting community - which includes allowing users to enter a free-text nickname and email address.

    Unfortunately, we occasionally have one minor troll who insists on pretending to be another member who he doesn't like. Doubly unfortunately, its' a situation where a simple IP ban isn't going to work.

    It's low level annoying behaviour, so what I'd quite like to do is add some kind of function that:

    1) Triggers when a new comment is added
    2) Checks whether the "name" field is a certain value, and if so what "email" was entered
    3) If the email isn't the actual members address, marks the comment for moderation so it doesn't insta-appear.

    I'm familiar with PHP and from googling realise that this probably involves adding a hook in the functions.php in my theme, I'm just a bit confused beyond that - which is annoying as it feels like this is probably something very simple if you know what you're doing!

    Any help would be appreciated...

  2. keesiemeijer
    moderator
    Posted 2 years ago #

  3. gariusthebrit
    Member
    Posted 2 years ago #

    Keesiemeijer - thanks, that almost but unfortunately doesn't quite, do what I need.

    BUT... looking at the code it also almost tells me enough about how to code it to allow me to roll my own mini-plugin that fires on "preprocess_comment" apart from one thing:

    If that plugin finds a mismatch, it just flat out throws a "wp_die" letting the individual know they've been naughty.

    I want to be a bit subtle - basically i'm not trying to bounce them - they'll just start varying their way of operating. I just want to make my moderation life easier. So ideally instead i'd want to either:

    1) Flag it for moderation
    2) Just quietly return them back to the page they came from (i.e. it effectively becomes a "refresh" rather than a "post" action).

    Any ideas?

  4. keesiemeijer
    moderator
    Posted 2 years ago #

    Unfortunately, we occasionally have one minor troll

    If it's just the one troll it is certainly doable. I don't have time right now, maybe tomorrow. Or if someone else wants to chime in, please do.

  5. gariusthebrit
    Member
    Posted 2 years ago #

    Yes - its just the one troll, which is why I'd rather do something like this than, say, turn on "first comment must be moderated."

    Seems silly to punish ourselves (and a whole community) because of the anti-social behaviour of one idiot.

  6. keesiemeijer
    moderator
    Posted 2 years ago #

    Try it with this in your theme's functions.php: http://pastebin.com/RdegSGXS

    Change the $valid_users array with valid usernames and their corresponding email addresses. If someone tries to use a username (in the array) that does not have the correct email their comment is sent to the moderation queue.

Topic Closed

This topic has been closed to new replies.

About this Topic