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

Adding and Removing Forum Profile Fields


Go to End


2 Posts   2396 Views

Avatar
gracie101

Community Member, 2 Posts

30 June 2009 at 8:42pm

New to SS and testing out the Forum module. What is the best way to hide/remove fields from the default forum registration profile page?

For example, I don't need a field for "occupation" or "website", but I do need a field for "product name". Thanks in advance.

Avatar
craigm

Community Member, 9 Posts

8 March 2010 at 4:33pm

Edited: 08/03/2010 4:45pm

old thread i know, but i just figured this out myself. so hopefully if anyone still hasn't figured this out yet, here's how to do it:

Theres 2 parts to adding a new field, adding the actual form field itself and then passing the fields input through to the database to be stored.

open the file: webroot/forum/code/ForumRole.php

In this file, go to the function 'getForumFields'. This is the one that creates the forum fields for the registration form. Firstly, comment out the ones that you dont want to be there. Then find the type of form field you want from the default ones and copy and paste it to a new line eg:

new TextField("database_column", _t('ForumRole.CUSTOMFIELD','form_label_name')),

replace 'database_column' and 'form_label_name' appropriately.

Then the next thing that you need to do is catch the data from the form and add it to the database.

In the same file, go back up to the 'extraStatics' function and add in a new array item to the nested 'db' array in the $fields array eg:

'database_column' => 'Varchar',

make sure that the database_column name is the same as you used in the getForumFields function and that you've specified the right data type.

Once you've saved this file, make sure that you run the database build string and the new field will get automatically added into the database:

http://localhost/dev/build?flush=1

and bobs your uncle.