I'm running latest D7. I've have a node comments enabled. Core permissions set that way that registered users can post without premoderation and guests can post their nickname and comment body which requires approval before beign published.
After enabling Antispam module with Defensio API (not sure if it matters) all unregistered user comments aren't showing their nicknames. I.e. everyone is shows as 'Guest'. Once I disable Antispam everything goes back to normal, nicknames are show (i.e. they aren't lost at least).
Reproducable: always, once I enable Antispam back again, every unregistered comment are shown as posted by 'Guest'.

CommentFileSizeAuthor
#6 antispam_guest_comments.patch381 bytesNStorm
#4 antispam_module.patch364 bytesNStorm
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joshhendo’s picture

I have the exact same issue, running on the latest version of Drupal 7 and the Anti-Spam module. For the time being I've had to disable the anti-spam module as I don't use registrations for my site, so everyone comments as Guest.

NStorm’s picture

Priority: Normal » Critical

Please fix this. This is really a blocker to use a module for a guest comments enabled sites (where it is most needed).

joshhendo’s picture

I'm not an antispam module developer, but I am a programmer, so I finally had a chance to see if it was easy enough to fix this (i.e. I didn't need a comprehensive understanding of the code to be able to get it to work.)

In short, yes, it's easily fixable. Open the file antispam.module. Go to line 970 and comment it out.

Before
$comment->name = variable_get('anonymous', t('Anonymous'));

After
// $comment->name = variable_get('anonymous', t('Anonymous'));

Alternatively, and admittedly a cleaner solution, you can delete lines 969 to 971 inclusive. So you will delete:

if ($comment->uid == 0) {
    $comment->name = variable_get('anonymous', t('Anonymous'));
}

The one downside to this is if there are any other instructions for altering the code that relies on line numbers, they will be off by 3.

I've only tested this on my development environment (which I only just got set back up) which doesn't have any spam going to it, but my main website has heaps of spam going to it so I'm going to test it out there now to make sure that it still filters spam properly and the names appear. To be honest though, I can't see any reason why those lines would affect the ability to stop spam!

NStorm’s picture

FileSize
364 bytes

Thanks @joshhendo for prodiving solution!
I really wonder why this was coded...
I've tested that patch on my site and it's working well.

EDIT: Just noticed - while commenting out that block does displays unregistered nicknames for other users, in comments and on the admin interface for the comment listing, they all are still shown as guests in the AntiSpam moderation queue.

NStorm’s picture

While digging on how to fix the antispam moderation I've found a more cleaner solution to a previous patch. Seems like this code are excepts to avoid situations with empty username, so it should be something like this:
if ($comment->uid == 0 && empty($comment->name)) {

And I've tracked down the issue with moderation queue, everyone are shown as guests to me even for registered users. It seems like this part in antispam.admin.inc are causing this:
$form['author'][$content->nid] = array('#value' => theme('username', array('name' => $content->name)));
...
$form['author'][$content->cid] = array('#value' => theme('username', array('name' => $content->name)));

Simply changing them to:
$form['author'][$content->nid] = array('#value' => ($content->name))
...
$form['author'][$content->cid] = array('#value' => ($content->name));

works for me. But it seems to be a dirty fix. Should be done somehow with theme(), but it shows everyone as guests for me as it was. I'm not really into Drupal code to make it better. Someone more familiar with it should take a look.

NStorm’s picture

FileSize
381 bytes
martin jinoch’s picture

I wonder why AntiSpam module needs to modify displayed username at all.

Solution in #3 (commenting out lines 969 to 971) works for me. Thanks for providing it, joshhendo

NStorm’s picture

Status: Active » Needs review
desmond54’s picture

Thanks. The patch provided by NStorm (#6) does the trick.

DamienMcKenna’s picture

Issue summary: View changes
Status: Needs review » Closed (duplicate)