Hi there,

I'm new to Drupal and these forums - please move this around if it's in the wrong place.

I'm setting up a social website using Drupal 6.10. My problem is that I would like to give registered users the ability to hide their username in forum comments and posts. Ideally, there would be a checkbox or radio button in the comment form that says something like "Hide my user name for this post", and they would get assigned some random alphanumeric string as an ID. I've installed Anonymous_Comments, but this is not what I was looking for, apparently. Can someone point me to a module, or custom PHP or just a discussion of this sort of issue?

Comments

WorldFallz’s picture

I don't know of any module that does this-- afaik, it would have to be custom coded. Probably with hook_comment and hook_form_alter.

There's a post on simply removing it (http://drupal.org/node/368776) but you'll have to add an option for a checkbox to do what you're looking for.

Vandaleur’s picture

Thanks. From a quick glance at this, it does look like it might be helpful.

grobemo’s picture

I'm working on a module that does this (though it's not the primary purpose of the module). You may find some of that code helpful. I've stripped it down quite a bit to remove various things related to the module's other purposes, so it may need to be tweaked a little. You can, of course, replace ANONYMOUS with whatever you want.

<?php

/**
 * Implementation of hook_comment()
 */
function YOUR_MODULE_comment(&$comment, $op) {
  if ($op == 'view' && $comment->preview != 'preview') {
    global $user;
 
    // Hide the comment author's name, unless the user has the right permissions or is the comment author.
    if (!user_access('administer comments') && $comment->uid != $user->uid) {
      $comment->name = t('ANONYMOUS');
    }

  }
}

?>

You might take a look at the Whisper module for some inspiration on adding a checkbox underneath a comment to suppress the name.

Vandaleur’s picture

Thanks grobemo!

I like the sound of Whisper - that may be exactly what we're looking for.