I am working on a project that allows user commenting without administrator approval if they post only text; however, if the user decides to attach an image to their comment, the comment should require approval first before being published. What is the best way to approach this?
2 Answers
I got this working using the Mollom module.
In Mollom's configuration, you can enable spam filtering and set up your own blacklist terms for the spam filter. I created blacklist terms for <img and "media-image" (TinyMCE's encoded image class). Then I told Mollom to "Retain the post for manual moderation" if it gets detected as spam.
You can create a module to do this by using the hook_comment_presave hook. If your module name is playx, then try this code:
function playx_comment_presave($comment) { if(strstr($comment->comment_body[$comment->language][0]['value'], '<img')){ $comment->status = 0; }
<img, then set the status to unpublished and send an email or something.check_plain()filter) as opposed to the raw data. See if there's a way to check the raw, unfiltered input.