0

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?

3
  • 1
    I think you could do this in Rules (drupal.org/project/rules) – act on a new comment being saved and then use a condition where the content contains the string <img, then set the status to unpublished and send an email or something. Commented Nov 16, 2012 at 18:57
  • @CharlieS I set up a text comparison condition in Rules and set "<img" (without quotes) as the matching text. It works if I enter "<img" as plain text, but if I upload an image it does not work. Commented Nov 16, 2012 at 20:38
  • It's probably comparing the text (whatever was inputted after it's been run through a check_plain() filter) as opposed to the raw data. See if there's a way to check the raw, unfiltered input. Commented Nov 19, 2012 at 1:47

2 Answers 2

0

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.

0

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; } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.