New value from registration page is not saved in database

Hi
I want to add a new field regarding user’s Degree in the registration and profile pages. this is what I did:

I added this code to “templates\user\register.tpl

<tr valign="top">
<td class="label">{fieldLabel name="degree" key="user.degree"}</td>
<td class="value"><input type="text" id="degree" name="degree" value="{$degree|escape}" size="5" maxlength="15" class="textField" />&nbsp;&nbsp;(PhD, MD, MSc, BSc)</td>
</tr>

and this code to “classes\user\form\RegistrationForm.inc.php

$user = new User();
$user->setData('degree',$this->getData('degree'));

and

function readInputData() {
        $userVars = array(
           'degree',......
            ....

but the entered value for Degree field is not saved in user_settings table.
Is there any other classes or functions that I should modify?
I am using OJS 2.4.6

Best,
Ali

Hi @alirezaaa,

You’ve got the front end (template and form) classes extended properly, but you’ll also need to extend the back end (DAO and data object) accordingly. Have a look at the UserDAO::getAdditionalFieldNames function; you’ll need to add the new field there.

Rather than using $user->getData and $user->setData, I’d suggest also adding getDegree and setDegree functions to the User class.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
Problem solved! I changed the field from InputText to <Select> and it makes more sense.
It is amazing how easily OJS could be customized (considering you know what you are doing and with the help of this forum!)
Thank you for your response.

Best,
Ali

1 Like

Hi @asmecher,
Regarding the new added fields to Author_Setting table, I have to make them searchable; but, I couldn’t find the corresponding class or functions that does the job. I want to include the item in the MySql query that is run on database (no change in template/interface files for now).
Please help me about what functions or classes should be modified and I will do the coding.

Best,

Are you wanting the search to be for the Journal Manager in the enrollment section? This search is usually field-specific.
The URL of “manager/people” would bring you to:

So the PeopleHandler manages the search.

I think you’ve already found and worked with the UserDAO.

Hi @ctgraham,
Thanks for the response.
I have to implement localized author and user names in OJS (I used this guide).
I have done the required coding for inserting localized data in database; now I need to retrieve them in the search page.
the User search in Management page is not so important for now and it can be done later. But, as you may guess it is very important to search the journal by author names.
Currently, authors’ firstname, middlename and lastname are saved in author_settings table as localized data (like affiliation for example).
I thought the search handler would search this table for localized names like the affiliation field; but, it doesn’t. and I can’t find the query to search author_settings table for authors’ name instead of the author table.
It seems that getPhraseResults function in ArticleSearchDAO.inc.php is the corresponding function. But, I couldn’t figure out how to modify it.
please help me on this search field and if I am on the right trail.
Cheers,

For the url of “search/search?..”, see pages/search/index.php for the “search” handler:

This points to:

Most the the work looks to be done by ArticleSearch. The include at the top of import('classes.search.ArticleSearch'); points us to:

You’re going to need to dive into this class, and the associated DAO:

Hi,
I’m facing the same problem. What did you do to fix the problem ? I mean, what did you do to store the field value on the database ? I have done all the steps mentioned here, but no success!
Thanks!