Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Forum Module /

Discuss the Forum Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Approval of new members in forum – is this best-Silverstripe-practise?


Go to End


2 Posts   1985 Views

Avatar
joelg

Community Member, 134 Posts

18 April 2009 at 8:08pm

Hi

I have a Silverstripe forum at www.finnlevinsen.com, but we needed the forum to be a bit more secure. Basically we needed to aprove new members before giving them access to post and read in the forum. The solution was to ad an "approved" boolean value in the function extraDBFields() in ForumRole.php like this:

$fields = array(
'db' => array(
'ForumRank' => 'Varchar',
'Occupation' => 'Varchar',
'Company' => 'Varchar',
'City' => 'Varchar',
'Country' => 'Varchar',
'Nickname' => 'Varchar',
'FirstNamePublic' => 'Boolean',
'SurnamePublic' => 'Boolean',
'OccupationPublic' => 'Boolean',
'CompanyPublic' => 'Boolean',
'CityPublic' => 'Boolean',
'CountryPublic' => 'Boolean',
'EmailPublic' => 'Boolean',
'Aproved' => 'Boolean',
'LastViewed' => 'SSDatetime',
'Signature' => 'Text'
),
'has_one' => array(
'Avatar' => 'Image'
),
'belongs_many_many' => array(
'ModeratedForums' => 'Forum'
),
'defaults' => array(
'ForumRank' => _t('ForumRole.COMMEMBER','Community Member')
),
'searchable_fields' => array(
'Nickname' => true
),
'indexes' => array(
'Nickname' => true,
),
);

And then in SinglePost.ss do a <% if CurrentMember.Aproved %> around everything that needed to be "hidden" from none-approved users.

However, I'm not sure if this is best practise? Any opinions?

Joel

Avatar
Willr

Forum Moderator, 5523 Posts

19 April 2009 at 5:42pm

Rather then edit the core files in the forum module - which makes upgrading the module later on more complex you could also try and use dataobjectdecorators to 'decorate' the member object from your own code (rather then adding it to that list) http://doc.silverstripe.com/doku.php?id=dataobjectdecorator