Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Adding new profile fields to the registration page
Hello, I used the search and read the doc so far but I couldnt find out how to modify the People.Class.UserManager.php to add the new post fields I added to the form in people_apply_form_nopostback.php
The sql date field exists in the database and here's what I've tried to do (not complete..I know)
but I am getting error messages and the values from the select boxes wont show up.
Any advice, link or comment is appreciated
The sql date field exists in the database and here's what I've tried to do (not complete..I know)
$BirthdayMerged = "0000-00-00";
if ($SafeUser->BirthDay<1 || $SafeUser->BirthMonth<1 || $SafeUser->BirthYear<1) $this->Context->WarningCollector->Add("Please check your birthdate again.");
$BirthdayMerged = $SafeUser->BirthYear."-".$SafeUser->BirthMonth."-".$SafeUser->BirthDay;
$s->AddFieldNameValue('Birthday', $BirthdayMerged);
but I am getting error messages and the values from the select boxes wont show up.
Any advice, link or comment is appreciated
0
This discussion has been closed.
Comments
$SafeUser->BirthDay = ForceIncomingInt('BirthDay', 0); $SafeUser->BirthMonth = ForceIncomingInt('BirthMonth', 0); $SafeUser->BirthYear = ForceIncomingInt('BirthYear', 0);
You can use these ForceIncomingX functions to get data from form fields or URL query strings. If you want to see all of them and how they work, they can be found in library/framework/Framework.Functions.php.
If anyone is interested, here's my approach (dont have much vanilla experience, so it might be clumsy)
appg\database.php
$DatabaseColumns['User']['Birthday'] = 'Birthday';
library\people/People.Class.UserManager.php
$SafeUser->BirthDay = ForceIncomingInt('BirthDay', 0); $SafeUser->BirthMonth = ForceIncomingInt('BirthMonth', 0); $SafeUser->BirthYear = ForceIncomingInt('BirthYear', 0); $BirthdayMerged = "0000-00-00"; $BirthdayMerged = $SafeUser->BirthYear."-".sprintf("%02d", $SafeUser->BirthMonth)."-".sprintf("%02d", $SafeUser->BirthDay); if ($SafeUser->BirthDay<1 || $SafeUser->BirthMonth<1 || $SafeUser->BirthYear<1) $this->Context->WarningCollector->Add("Du musst ein korrektes Geburtsdatum angeben.");
themes\people_apply_form_nopostback.php
// BirthDay // $Select = $this->Context->ObjectFactory->NewContextObject($this->Context, 'Select'); $Select->Name = "BirthDay"; $Select->SelectedValue = ForceIncomingInt('BirthDay', 0); $Select->AddOption('0','TT'); for($i=1; $i<32; $i++) { $d = sprintf("%02d", $i); $Select->AddOption($d, $i); } $birthday1 = $Select->Get(); // BirthMonth // $Select = $this->Context->ObjectFactory->NewContextObject($this->Context, 'Select'); $Select->Name = "BirthMonth"; $Select->SelectedValue = ForceIncomingInt('BirthMonth', 0); $birthmonths = array("--","Jan","Feb","Mrz","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"); $Select->AddOption('0','MM'); for($i=1; $i<13; $i++) { $m = sprintf("%02d", $i); $Select->AddOption($m, $birthmonths[$i]); } $birthday2 = $Select->Get(); // BirthYear // $Select = $this->Context->ObjectFactory->NewContextObject($this->Context, 'Select'); $Select->Name = "BirthYear"; $Select->SelectedValue = ForceIncomingInt('BirthYear', 0); $Select->AddOption('0','JJJJ'); for($i=(date('Y')-16);$i>=date('Y')-85;$i--) $Select->AddOption($i, $i); $birthday3 = $Select->Get(); echo ' <li> <label for="selBirthday">Birthday</label> '.$birthday1.' '.$birthday2.' '.$birthday3.' </li> ';
(including some German fragments)
The only "problem" is/was that the incoming ints function removed the leading zero which is important for a correct date field..
The ability to add custom fields such as this to the application form would be amazing.
This is what i've been needing. thank you.