How to change fields in participants' profiles / registration

How to change fields in participants' profiles / registration

by Uwe Klemm -
Number of replies: 23
Hi,

I'm sure someone must have had this problem and tackled it - but I haven't been able to find a solution yet.
I'm running Moodle 1.6.4 and want to implement some changes in the form fields that appear in the participants' profiles. For instance, I want to make it obligatory to fill in "institution". Plus, I'd love to add some fields.
How can that be achieved?
Any help is greatly appreciated,
Uwe
Average of ratings: -
In reply to Uwe Klemm

Re: How to change fields in participants' profiles / registration

by John Mc Hale -

It depends on whether the user is:

1. creating a new account (e-mail authentication), or

2. editing an existing profile.

In case (1), you will need to make (CAREFUL) changes to both signup_form.html and signup.php in the /login directory of your Moodle site.

In the second case, you will need to make (CAREFUL) changes to both edit.html and edit.php in the /user directory of your Moodle site.

While the following procedure applies to new 'sign-up' accounts, I would imagine that the changes to edit.html and edit.php for existing users are somewhat similar.

As an example, suppose you want to add the field 'Institution' to the sign-up form for new users, the following are the steps you would require:

1. Open the file sign_up.html using html editor that allows you to view both design and code (I use Dreamweaver).

2. Near the top of the file, you should see a PHP code block, initialising variables. In this block, include an initialiser for institution (I placed this between the $user->lastname and $user->city initialisers).


   if (empty($user->institution)) {
       $user->institution = "";
   }

3. Further down the sign_up.html, the form fields displayed to the user appear between <tr></tr> tags. The easiest way to add a new one is to copy and paste a complete block and make changes as required; e.g.

<tr valign="top">
            <td align="right">
     <?php print_string("institution") ?>
     :</td>
            <td>
     <input type="text" name="institution" size="40" value="<?php p($user->institution) ?>" alt="<?php print_string("institution") ?>" />
              <?php if (!empty($err->institution)) { formerr($err->institution);} ?>
   </td>
          </tr>

4. Save changes and close sign_up.html.

5. Open your language file; e.g. /lang/en_utf8 and add a new language string:

$string['missinginstitution'] = 'Missing institution';

6. Save and close language file. 

7. Open signup.php and find the function validate_form (near the bottom)

8. Include your new validation clause:

if (empty($user->institution)) {

$err->city = get_string("missinginstitution");

}

9. Save and close signup.php

10. Test

In reply to John Mc Hale

Re: How to change fields in participants' profiles / registration

by Uwe Klemm -
John -

thanks an awful lot for the detailed help. Your solution did the trick, the new registration procedure seems to work like charm.
Great smile

Thanks,
Uwe
In reply to John Mc Hale

Re: How to change fields in participants' profiles / registration

by Tina Treutler -
When I'm using Moodle 1.8, I don't have a signup_form.html - just a .php file. How do the field changes work there?
In reply to Tina Treutler

Re: How to change fields in participants' profiles / registration

by Andrew Tran -

im having the same problem with moodle 1.8,

those files dont exist  in the /login directory

there is only similar files suchas

index_form.html

signup.php

signup_form.php

do the same changes apply?

In reply to Tina Treutler

Re: How to change fields in participants' profiles / registration

by Just H -
Tina and Andrew, have you tried doing what you want with the new functionality built into 1.8?

H
In reply to Just H

Re: How to change fields in participants' profiles / registration

by Andrew Tran -

Hey, ive tried the new functionality in 1.8, thought im not sure how to make it appear in the create new account form.

any ideas?

In reply to Andrew Tran

Re: How to change fields in participants' profiles / registration

by Ray Lawrence -
Does this help... MDL-9702
In reply to Ray Lawrence

Re: How to change fields in participants' profiles / registration

by Heather P -
Just to make sure I'm understanding what I'm reading. Does this mean that the user profile fields thing isn't currently working yet?
The help documentation isn't a great deal of help yet. I'm sure it will be super eventually but not yet.
This page looks like you are meant to be able to add fields but not take them away, is that right, or have I lost the plot entirely or is it because it isn't actually doing as intended yet?
Thanks
In reply to Just H

Re: How to change fields in participants' profiles / registration

by Arturo Israel García Castro -
I've used that to get info that is not considered in moodle default fields, but now i want some default fields to be present (like Institution and Department) and set them as required. I'd be possible for me to modify carefully the signup.php and signup_form files, but i'm worried about future updates... are these modified files going to be overwriten in next update? What could be a good way to implement this?

adding repeated Institution user custom fields?


thanks in advance.
In reply to John Mc Hale

Re: How to change fields in participants' profiles / registration

by Nicola Bennett -

Hi John,

I was wondering if you could help me. I have managed to add two new fields to the sign up form - School and State, see attached image.

The form is all working fine except when a user creates a new account the new fields are not appearing in their profile.

Do you know how to get the new fields to appear on the profile page?

Hope you can help, this has got me puzzled.

Thanks in advance
Nicola.

Attachment sign_up_form.jpg
In reply to Nicola Bennett

Re: How to change fields in participants' profiles / registration

by Daniele Cordella -
Picture of Core developers Picture of Plugin developers
I feel Ray already posted the answer.
It is still not possible. It was requested. The request is MDL-9702.
Up to now, the user who get in has to go to edit his/her personal profile and only there he/she will be requested to fill all extra fields.
Go to vote for this feature request. Maybe this will push developers.
In reply to Daniele Cordella

Re: How to change fields in participants' profiles / registration

by Nicola Bennett -

According to John McHale's post below this can be done.

I assume if the fields can be added to the form, then these fields can be transferred to the profile page?

John, please can you confirm this.

Thanks.

In reply to Nicola Bennett

Re: How to change fields in participants' profiles / registration

by Nicola Bennett -

I've now solved this.

You need to use one of the existing fields in the profile and change the name in the language file to be the same as the new field on your sign up form.

For example in the language file I've changed 'institution' to 'School/District/Organization'

In reply to Nicola Bennett

Re: How to change fields in participants' profiles / registration

by Uwe Klemm -
Nicola -

could you please write which language file precisely you edited?
I assume that if your Moodle installation uses different languages all respective language files will have to be edited?

Thanks in advance,
Uwe
In reply to Uwe Klemm

Re: How to change fields in participants' profiles / registration

by Juan Marín -
The moodle.php file.


Uhm! I'm afraid that this changes must be done in all the language files... And this could be a problem when you upgrade languages if you don't use local languages packs (but if you have a lot of possible languages it is a hard work to create a local language for each)
In reply to Nicola Bennett

Re: How to change fields in participants' profiles / registration

by john h -
I see you mentioned existing fields, what about new fields?

Also, some of my profile fields I want available for registration are drop down menu.

What to do?
In reply to Nicola Bennett

Re: How to change fields in participants' profiles / registration

by Juan Marín -
Hi Nicola,
With 1.7 I used existing fields for my customized sign up and edit profile forms, but I don't know how to use this trick with 1.8.2. The edit.html and sign_up_form.html are now .php files.

The new feature proposed by harry is not enough for me:
  • in sign-up form, I need my students insert their university ID code in the registration form as mandatory field (I use an existing field for it, but I need to show it in the registration form. Otherwise, my students forgot to update their profile after the registration)
  • In edit profile, I need this "ID code" to be in the required group and not in "optional" (it should be showed in the standard profile view form and not in advanced form)
I hope this can be done in 1.9 (move fields from a category to other: required, optional, others, ...) (MDL-9702).

But NOW?
Could somebody give any guide to edit (carefully) the user/editform. php and editadvancedform.php AND login/signup_form.php to change the order or the category (requiered vs optional) were the fields are showed?

Perhaps there are a file or a table where the fields and their properties are stored. In this case I could set manually the category and the tab order of this field... (I could survive changing only the category, the order is not essential)

It sounds easy ... but I have no idea where this information is stored.

Thanks in advance,

In reply to Juan Marín

Re: How to change fields in participants' profiles / registration

by Juan Marín -
Huum!

perhaps the solution is already avalaible:
http://docs.moodle.org/en/Development:Customisable_user_profiles

and

http://moodle.org/mod/forum/discuss.php?d=55814

If somebody has proved it yet, I would kindly appreciate their comments: I'm not sure if the procedures recommended in this links are easy for dummies like me mixed
In reply to Juan Marín

Re: How to change fields in participants' profiles / registration

by Juan Marín -
Not fixed yet.

Using the new "user profile fields" solve the need to edit the user/editprofile_form.php
(it is enought for me)

But don't solve the signup problem (most important to me)
Perhaps, in 1.9 is fixed if the flag signup - the field should appear on the signup page, would be activated.
But in 1.8 I couldn't found any way to mark a "new field" (or using "existing fields") to be placed in signup form.

Another thing to fix is to show the description in the signup form (not only the long name). I need to show some instructions/norms to the students in order to fill the fields correctly.

What I want to do is present this login form in 1.8.2 (this figure attached shows what I'm using in 1.7.2):


Attachment image002.jpg
In reply to Nicola Bennett

Re: How to change fields in participants' profiles / registration

by John Mc Hale -

Sorry Nicola,

Only getting back to Moodling today after a short lay-off!

Glad to see that you've managed to sort this out!

Regards.

In reply to John Mc Hale

Re: How to change fields in participants' profiles / registration

by Rambabu Dola -
Hi Jhon,


Could you pls tell "How to change fields in participants' profiles / registration".

Iam using moodle 1.9.5+ .

Thanks
rambabu