How can I add a required field in New User Registration Form?

Hi all,

In our journal authors’ ORCID ID is required information and I want to add user ORCID ID in register form Profile section.
Ekran%20Al%C4%B1nt%C4%B1s%C4%B1

How can I add this field?

Thanks in advance.

1 Like

Use the orcidProfile plugin for the basis of this functionality:

I think you would need to make a modification to make the ORCID required; but if you made this an option within the plugin it might make for a good pull request.

You’re right. I want to make a modification to make the ORCID required. I made this for OJS2 and it was too easy. I didn’t find how I can modify this.

Currently, the plugin exposes the new field on the template:

And processes that new field on user registration:

It sounds like you would also want to hook into the form validation. You would use similar logic, but with the validation hook. There is an example of such a validation hook here:

I applied this solution bu unfortunately it doesn’t work. Orcid is additionally information and it exists in both PKPUserDAO.inc.php and RegistrationForm.inc.php. I want to learn that how can I change the orcid variable required? I checked out the related titles in the forum but I didn’t find how I can convert a variable to the required in the registration form.

Making a field required is a function of the form validation. (Hence, the “registrationform::validate” hook.

Can you share the code you tried, but which didn’t work? Forking the orcidProfile repository in GitHub would be ideal, but you can also share code directly in the forum, if needed.

I downloaded master branch orcid profile plugin and uploaded in plugins/generic folder. The changes already made those you give above in the OrcidProfilePlugin.inc.php. I activated the ORCID Profile plugin in Settings/Website/Plugins. When I enter the new user register, the page doesn’t work. There isn’t any error information about this in the error.log

If you manually uploaded the plugin files (outside of the plugin gallery), did you run the upgrade script to register the new plugin?

What specific version of OJS are you using?

What specifically happens when you enter the new user registration page?

My OJS version is 3.1.1.4. After uploaded plugin the new user registration page didn’t work. I didn’t run the upgrade script.

When installing a new generic plugin, the plugin must be registered with the application. This happens automatically when uploading a plugin through the Plugin Gallery. If the files are copied manually, the best way to register the plugin is to re-run the OJS upgrade script, either from the command line or through the web interface:

Alec you’re right. I’m already doing it. But before upgrading need to be careful. Because if the plugin is wrong version this upgrading can disrupt the db. I also uploaded a plugin about most read artciles and I’ve been trying to fix it since last night. At the end I can not reach Installed Plugins.

Hi @ctgraham,
I need to add a new field in registration form to be saved in the user profile, in ojs 3.1.0.1. However we do not want to modify the source code. We only would do it by adding a plugin. I was wondering if it is possible at all. I noticed there is already a setOrcid function that was used in orcidProfile plugin. How ever we cannot add a corresponding functin in core. Have you got any suggestion for this?

Regards
Ghazal

This can be done entirely with a plugin calling core hooks.

For example, you can add a new datafield to a user:

You can add a field to a form, such as the registration form, as described above:

@ctgraham, Thanks so much for the help.
I made the new filed working on the registration form using the new plugin. I need to display it and make it available for edit in public profile tab as well. It displays the value saved at registration time. But I cannot save the edited value. I believe I need to a hook to be able to that. I have used User::PublicProfile::AdditionalItems for displaying in the user profile. Is there any hook for me to use to save it?

Thanks heaps.
Ghazal

I managed to find the right hook. It was publicprofileform::execute which worked for me.
Thanks

1 Like