Once more about adding new fields to registration form

Good day.
I need to add ‘Date of Birth’ and ‘Upload file’ fields to user registration form in OCS 2.3.6.0
I’ve searched through the forum and was lucky enough to find some corresponding threads with clear and understandable explanations. Unfortunately, they refer to OJS, where it seems to be another file hierarchy.
I’ve already edited createAccount.tpl. Successfully.

code
<tr valign="top">
	<td class="label">{fieldLabel name="dateofbirth" key="user.dateofbirth"}</td>
	<td class="value">
           <input type="date" id="dateofbirth" name="dateofbirth" value="{$dateofbirth|escape}" class="textField" />&nbsp;&nbsp;{translate key="user.dateofbirthExample"}
       </td>
</tr>

Now, I suppose I have to edit ‘UserDAO.inc.php’ and ‘CreateAccountForm.inc.php’ files, but not absolutely sure,
I’ll be grateful if you could specify the correct locations.
Thank you very much.

Well, I tried to edit PKPUser.inc.php :

function getDateOfBirth() {
	return $this->getData('dateofbirth');
}
function setDateOfBirth($dateofbirth) {
	return $this->setData('dateofbirth', $dateofbirth);
}

and PKPUserDAO.inc.php :

define(‘USER_FIELD_DATEOFBIRTH’, ‘dateofbirth’);

function &_returnUserFromRow(&$row, $callHook = true) {

$user->setDateOfBirth($row[‘dateofbirth’]);

}

read more...
function insertUser(&$user) {
	if ($user->getDateRegistered() == null) {
		$user->setDateRegistered(Core::getCurrentDate());
	}
	if ($user->getDateLastLogin() == null) {
		$user->setDateLastLogin(Core::getCurrentDate());
	}
	$this->update(
		sprintf('INSERT INTO users
			(username, password, salutation, first_name, middle_name, initials, last_name, dateofbirth, gender, affiliation, email, url, phone, fax, mailing_address, country, locales, date_last_email, date_registered, date_validated, date_last_login, must_change_password, disabled, disabled_reason, auth_id, auth_str)
			VALUES
			(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, %s, %s, %s, %s, ?, ?, ?, ?, ?)',
			$this->datetimeToDB($user->getDateLastEmail()), $this->datetimeToDB($user->getDateRegistered()), $this->datetimeToDB($user->getDateValidated()), $this->datetimeToDB($user->getDateLastLogin())),
		array(
			$user->getUsername(),
			$user->getPassword(),
			$user->getSalutation(),
			$user->getFirstName(),
			$user->getMiddleName(),
			$user->getInitials(),
			$user->getLastName(),
			$user->getDateOfBirth(),
			$user->getGender(),
			$user->getAffiliation(),
			$user->getEmail(),
			$user->getUrl(),
			$user->getPhone(),
			$user->getFax(),
			$user->getMailingAddress(),
			$user->getCountry(),
			join(':', $user->getLocales()),
			$user->getMustChangePassword() ? 1 : 0,
			$user->getDisabled() ? 1 : 0,
			$user->getDisabledReason(),
			$user->getAuthId()=='' ? null : (int) $user->getAuthId(),
			$user->getAuthStr()
		)
	);

function updateObject(&$user) {
	if ($user->getDateLastLogin() == null) {
		$user->setDateLastLogin(Core::getCurrentDate());
	}

	$this->updateLocaleFields($user);

	return $this->update(
		sprintf('UPDATE	users
			SET	username = ?,
				password = ?,
				salutation = ?,
				first_name = ?,
				middle_name = ?,
				initials = ?,
				last_name = ?,
				dateofbirth = ?,
				gender = ?,
				affiliation = ?,
				email = ?,
				url = ?,
				phone = ?,
				fax = ?,
				mailing_address = ?,
				country = ?,
				locales = ?,
				date_last_email = %s,
				date_validated = %s,
				date_last_login = %s,
				must_change_password = ?,
				disabled = ?,
				disabled_reason = ?,
				auth_id = ?,
				auth_str = ?
			WHERE	user_id = ?',
			$this->datetimeToDB($user->getDateLastEmail()), $this->datetimeToDB($user->getDateValidated()), $this->datetimeToDB($user->getDateLastLogin())),
		array(
			$user->getUsername(),
			$user->getPassword(),
			$user->getSalutation(),
			$user->getFirstName(),
			$user->getMiddleName(),
			$user->getInitials(),
			$user->getLastName(),
			$user->getDateOfBirth(),
			$user->getGender(),
			$user->getAffiliation(),
			$user->getEmail(),
			$user->getUrl(),
			$user->getPhone(),
			$user->getFax(),
			$user->getMailingAddress(),
			$user->getCountry(),
			join(':', $user->getLocales()),
			$user->getMustChangePassword() ? 1 : 0,
			$user->getDisabled() ? 1 : 0,
			$user->getDisabledReason(),
			$user->getAuthId()=='' ? null : (int) $user->getAuthId(),
			$user->getAuthStr(),
			(int) $user->getId(),
		)
	);
}

and so on, by the analogy with other fields…

And now I have DB error: Unknown field ‘dateofbirth’.
Does it mean I have to manually prepare DB somehow or did I miss something?

Hi @Maxim_Zhupikov,

Definitely you at least have to add the new field in the Users DB table. If that is enough, I am not sure. Try and see.

Regards, Primož

Thank you!
It seems that was enough.
At first glance at least.