OJS 3.1.0.1 Need to add custom fields to the submission form

Hello there!

I’m struggle with a petition from a client that wants to add some custom fields to her submission form. Those fields are for name, university and academics degrees of the article author, but I’m not sure how to add this fields to the form.

¿There’s a way or a plugin that I can use to add those to the form?

Hello, @asmecher!

Can you help me with this? Or hand me a little guide or a post which achieve this. Please

Hi @daniel.anez

Unfortunately, I don’t know such plugin but I have done similar work recently. Are you familiar with the creation of a child theme?
For adding custom field in the submission metadata form, I’ve overridden submissionMetadataFormTitleFields.tpl from a theme plugin and have used following hooks:

issueentrysubmissionreviewform::initdata
issueentrysubmissionreviewform::readuservars
issueentrysubmissionreviewform::execute

But in your case, I suppose you need to override userDetails.tpl, as those data are related to authors. You can find it under lib/pkp/templates/common/userDetails.tpl.
At first glance, you need to work with UserDetailsForm class. So, I expect that these hooks can be used:

userdetailsform::initdata
userdetailsform::readuservars
userdetailsform::execute
userdao::getLocaleFieldNames

The latter should be changed to userdao::getAdditionalFieldNames if the input field is not localized.
Also, you can find an example on how to work with similar hooks in the Immersion theme: https://github.com/pkp/immersion/blob/master/ImmersionThemePlugin.inc.php#L58-L60

Hi @Vitaliy!

Ok, I will try that way. Appearently I was modifying the wrong files.

I will try it today and coming back to update the post with the results.

Hi @Vitaliy

I was making the changes you were mentioned but my client just told me that no all the authors are users, so changing the usersDetails and the users files wont cover what my cliente needs.

I was thinking about adding those fields on the submission metadata form, just like you did, but I’m lack of information of which or where are the files that I must change to achieve that.

Can you give me a little help telling me where can I find those files, please?

@asmecher @NateWr can you guys help me with this? I’m struggle trying to understand the whole backend and I have no previous experience developing in ojs but I do have developing in html, css, php and js.

OJS has significant amount of hooks that can help to inject a custom code in many parts of the system from a plugin. I haven’t got many experience with other CMSs/frameworks but it should be similar. To call a hook from a plugin one needs to call a static method like [here] (https://github.com/pkp/immersion/blob/master/ImmersionThemePlugin.inc.php#L48-L63) inside the ::init method. Then work with passed parameters. This is similar to PHP’s callback functions, like usort.
I recommend exploring plugins that are already written to understand the mechanism.

Regarding forms, you need to inject data to such methods as initData, execute, readUserVars. The hooks are registered here. All forms extend this class and inherit the hooks.

Using the hooks that @Vitaliy has described is your best bet. The form you’ll need to hook into is AuthorForm: https://github.com/pkp/pkp-lib/blob/master/controllers/grid/users/author/form/AuthorForm.inc.php

And the template for that form is https://github.com/pkp/pkp-lib/blob/master/templates/controllers/grid/users/author/form/authorForm.tpl.

Thank you very much @NateWr.

We have a small team trying to achieve that. I’ll notify you when we achieve it.