DNNCommunity / DNNCommunity/DNN.Blog

Unauthenticated user names do not appear on comments (_default Skin)

Open
#105 1 comment 0 reactions 0 assignees View on GitHub
waiting for reply
Dominant language
JavaScript
Stars
39
Forks
41
PR merge metrics
No merged PRs in 30d

Description

Whenever an unauthenticated (anonymous) user enters a comment, they are required to enter a name (which could simply be an alias or one-time screenname), but that name does not appear on the comment when the post is displayed. Instead, only a placeholder icon for an unavailable profile pic appears.

It seems that this name should be displayed, just as the display name for an authenticated user is displayed on their comments. (Sometimes a commenter may be a someone whose name is recognizable, but for whatever reason, that person has chosen not to create a site login or has simply decided to comment without logging in. In these cases, it is helpful to see the name associated with the comment.)

This behavior can be added to the template's Comment.html file as follows:

Old code:
```


```

New code:
```




if ([comment:createdbyuserid] == -1) {
document.getElementById("anonDisplayName").innerHTML='[comment:displayname]';
}

[commenter:displayname]

```

The JavaScript addition works by making a couple of assumptions:

1. The comment's underlying CreatedByUserID field will always be set to -1 when a comment is added by an unauthenticated/anonymous user.
2. The old HTML code (which generates a link to the user profile) will always fail to generate any HTML for an unauthenticated/anonymous user (this code is always evaluated).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.