You can add your own custom attributes (for example, name and address) to a user.
First you have to turn on Public Registration (it’s off by default)
Dashboard > System and Settings > Login and Registration > Public Registration
Under “Allow Visitors to Signup as Members” select “On – email validation” (You can choose the other options but this one has been recommend to me, so this is the one I chose).
Then
Dashboard > Members > Attributes
Select or create new attributes and then check “Show on Registration Form“.
Checking this box tells Concrete5 to put this on the registration form. Specifically, in the file:
concrete/controllers/register.php
- under the methond named do_register():
$aks = UserAttributeKey::getRegistrationList();
getRegistrationList() gets all of the attributes which have “Show on Registration Form” checked. If the user filled out that field, then it gets added as a User Attribute.
There are a few posts on how to make a custom registration page so I won’t go into detail about that.
The simplest thing to do is create a single page that will hold your form, then use a bit of Javascript and PHP to “pre-fill” the fields with your User Attributes.
Under the controllers folder (your controllers folder, not the concrete/controllers folder) create a file called sample.php.This is your controller file.
Under the single_pages folder create a file called sample.php. This is your view file.
Then go to the Dashboard > Pages and Themes > Single Pages and create a file called sample.
Single pages usually default to view.php, and any content you place in say, single_pages/sample.php will show up where you place:
<?php
print $innerContent;
?>
This bit of code goes into your view.php file (in your theme folder) where you want to place the content from your view (in your single_pages folder…in this case, the file called sample.php which is in the single_pages folder).
Alternately, you can create a template with the same name as the controller and view (in this case, sample.php) drop that file into your theme folder, and that will work too (instead of using view.php). This gives you the chance to customize the look and feel a bit more.
Go to Dashboard > Sitemap and find your page (sample).
Go to view the page and add a form block.
Add some questions to the block and then click “Add”. Once you are done, view the HTML source of the form.
Your inputs will look like:
<input type="text" name="QuestionNumber" value="">
Where I wrote “QuestionNumber” it’s usually a number like “Question24″ or “Question8″. Write these down for the inputs you want to pre-fill.
Remember, “special thing” gets passed to the view from the controller by:
$this->set('special_thing', $special_thing);
To see the result, if you have permalinks turned on, you can go to sample/form/ to see how it works. If it’s not working, view your source to see if the javascript is getting the values from your controller file.
Pros
Easier than trying to override the form block.
Cons:
Uses Javascript. However, since this only pre-fills the form out for the user, it doesn’t actually prevent the user from using the form (they just have to type in more information without javacript turned on).