General help

How can you move Other FIelds and Optional Fields into the General section of Add New User

 
 
Picture of jeff sherk
How can you move Other FIelds and Optional Fields into the General section of Add New User
 
I'm using Moodle 1.9. I searched the forums, but was not able to locate ay information on this topic...

Question #1:
There are some Optional Fields and some custom Other Fields that I would like to move up into the General section when adding a new user.
For example, I have a State/Province field that I would like to appear after City and before Country. I also want to move the Address field up before the City field. This is just to make things appear more normal for people filling out the form... these are the normal places that you would see these things. The current locations, down at the bottom of the form are not very intuitive locations to find these fields.

Question #2:
How can you change which fields are affected by the Show/Hide Advanced button on this form?
For example, when set to "Hide Advanced" I would still like the Address field to be visible, but I would like the "Email Activated" field to be hidden.

Thanks

 
Average of ratings: -
Picture of John White
Re: How can you move Other FIelds and Optional Fields into the General section of Add New User
 
Jeff,

Q1...
To actually get your field into the General section will be tricky because in 1.9 (at least) the fields are hard-coded in more than one place in the php,
only the additional categories and fields that you set up in...
Users->User Profile Fields
...appear as fields of fields (if you see what I mean), within the database!
There you have a hierachy of...
mdl_user_info_category
mdl_user_info_field
mdl_user_info_data
...but that doesn't help you move an info field into the general list!

Are the people filling out the form using email-based self-registration?
You may have to edit:
/login/signup_form.php
...moving the function call profile_signup_fields($mform); upwards in the file.
But this would move all those Other Fields that you have ticked as 'Display on signup page' upwards!

Are the people filling out the form doing so as administrators?
You may have to edit:
/user/editlib.php
...where function useredit_shared_definition is defined, which is called from...
/user/editadvanced_form.php

Is this for all authenticated users?
This may also mean editing the function call useredit_shared_definition in:
/user/editlib.php
...which is also called by /user/edit.php

In short there is a big question mark over how much trouble it will be to achieve this change!


Q2.
If you do decide to edit /user/editlib.php so as to change the hard-coding referred to above, then note that the call to:
$mform->setAdvanced('xxx');
...sets the field 'xxx' to belong to the Advanced set, so this is something that can be added or removed as required I guess.


Hope there is something useful here.
Regards,

John



 
Average of ratings: -
Picture of jeff sherk
Re: How can you move Other FIelds and Optional Fields into the General section of Add New User
 
Thanks for the reply John...

Q1
I thought it might only be a simple "move some code around" solution to get the stuff to appear in the General section, but obviously it is much more involved than what I want to get involved with! Are there any plans in a future release of Moodle to make these fields "moveable" or "assignable" to different sections? Any tracker issues I could vote for?

Q2
The $mform->setAdvanced('xxx') in editlib.php must not be the only place that this is set, since that line does not exist for the Phone1, Phone2 and Address fields, yet those three fields still get hidden when you hit the Hide Advanced button.
It works for hiding a few fields that I don't want displayed, but I can't unhide those optional fields!!
 
Average of ratings: -
Picture of jeff sherk
Re: How can you move Other FIelds and Optional Fields into the General section of Add New User
 
I figured Q2 out... you need to remove (comment out) the following line:
$mform->setAdvanced('moodle_optional')

otherwise the whole Optional section is hidden when you click the Hide button. With this above line commented out, you can then assign the setAdvanced option to whichever optional field you want to be hidden when the button is pressed.


 
Average of ratings:Useful (1)