Hi,
I use a forum in a 'members only' secure part of a Silverstripe site that requires a member login. That means in my setup all members get added manually in the CMS security tab.
I would like to automatically create a default nickname from 'FirstName Surname'. At the moment when I create a new member in the CMS the nickname field is empty and the user appears as 'anonymous' in the frontend.
OK, the main question is: Does anyone have an idea how to create a default nickname on user creation in the CMS? Any hints are highly appreciated.
Alternatively I thought I could set the defaults for FirstNamePublic and SurnamePublic to true in ForumRole.php (added lines in green):
'defaults' => array(
'ForumRank' => _t('ForumRole.COMMEMBER','Community Member'),
'FirstNamePublic' => 1, // added
'SurnamePublic' => 1, // added
),
I think if a member doesn't have a Nickname and FirstNamePublic is set to true it should then show the FirstName instead of 'anonymous' (and 'FirstName Surname' after a little tweak in the same file:
function Nickname() {
if($this->owner->Nickname) return $this->owner->Nickname;
elseif($this->owner->FirstNamePublic && $this->owner->FirstName) return $this->owner->FirstName.' '.$this->owner->Surname;
else return _t('ForumRole.ANONYMOUS','Anonymous user');
}
This only works for the author name next to a post. In all other cases it still says 'Anonymous' or 'Anon'. Does anyone have any ideas? I still think that the first approach to create a default nickname from first and last name on user creation in the CMS would work best...
Cheers!
Anatol