Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
How can I add a custom field in Vanilla Registration form?
![Trideep](https://secure.gravatar.com/avatar/dae35ab346f6352e5c6ca318607bf8d8/?default=https%3A%2F%2Fvanillicon.com%2Fd33acd0a4a32ab9cf123e9c65398b411_100.png&rating=g&size=100)
I want to add a custom field eg. STUDENT ID CARD NO. in registration form, after submitting the form it should check the forum database if already the same STUDENT ID CARD NO. exists then returns to the registration form with error text...
Can anyone please help me out?
0
Answers
If you upgrade to 2.1.1, you can use profile extender: https://github.com/vanilla/vanilla/tree/2.1/plugins/ProfileExtender
Can I check the forum database using this plugin, if already the same STUDENT ID CARD NO. exists then returns to the registration form with error text.?
The information is loaded on the database, so it should be doable. Maybe someone with a bit more finesse can help you on that.
You would need a custom plugin, because ProfileExtender processes additional registration fields after user has been created.
Good point @R_J![:) :)](https://open.vanillaforums.com/plugins/emojiextender/emoji/little/smile.png)
@Trideep
I could write you a custom plugin for a donation, if no one else details all the necessary code for you you can pm me if you like.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Using Profile extender doesn't allow for Validation rules to be automatically applied.
You would need to hook into the user model and do your unique validation code.
I think you would find that using profile extender will make life difficult in terms of trying to find if a student id has already been used. Adding your own column would greatly simplify the process of determining if the student ID has already been used.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
But it does enforce schema. If student ids are unique, then they need a unique index in the database.
grep is your friend.
The moral of the story would be to create a new column in the User table and make it a unique index. Then you just have to spit out a textbox with the same column name and Vanilla will validate it for you automatically.
Below is a minimum viable plugin that requires a unique student ID number:
EDIT - I don't really like the form of the error returned. Is there an easy way to hook into the schema validation? I couldn't find anything.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
If you read the comments in the profile extender, you'll see that it will add the the custom fields to the User table if the column already exists in the User table. So that's what I did, used phpmyadmin and added a few columns, then installed profile extender and told it to use those columns and require users to enter data into those fields upon registration.