General developer forum

 
 
Picture of Kenneth Newquist
Making Required Profile Fields Optional
 
I didn't see an interface specific forum, so I figured I'd post this here.

We'd like to change certain required profile fields (city, country, description) to optional. What's the best way of doing that?

We've found that these fields are causing confusion and headaches with students (particularly the description field, which most don't want to update, but are forced to change if they want to make other tweaks to their profile).

 
Average of ratings: -
Picture of seaghan moriarty
Re: Making Required Profile Fields Optional
 
Hi Kenneth,

this is indeed a royal pain - especially when the red-box-around error is not visible onscreen (it is up at the top of the page).

Have you been able to find a workaround? Surely the 'compulsory' tag is available to edit in some settings? I've been searching but cannot find an answer. THanks!
 
Average of ratings: -
Picture of Joe Murphy
Re: Making Required Profile Fields Optional
Group Testers
I too am searching for an answer for this. If anyone has a workaround, I'd love to see it... this is proving a major problem with our incoming freshmen.
 
Average of ratings: -
Picture of Michael |
Re: Making Required Profile Fields Optional
 
If you haven't found an answer yet, you can try editing the "useredit_shared_definition()" function in the user/editlib.php approx line 57, commenting out the code that makes it required.

For example to make 'city' not required you'd change:

$mform->addRule('city', $strrequired, 'required', null, 'client');

to

//$mform->addRule('city', $strrequired, 'required', null, 'client');

I haven't fully tested but this looks like it'd work as a last resort.




 
Average of ratings: -
Picture of Ian Scott
Re: Making Required Profile Fields Optional
 
You will also need to do this in the file edit_form.php if you want the Description field not to be compulsory.
 
Average of ratings: -
Picture of Zoe Bogner
Re: Making Required Profile Fields Optional
 
Thanks Ian, you just saved me a lot of time!

Why isn't that line in editlib.php with all the others?
 
Average of ratings: -
Picture of Zak Fleming
Re: Making Required Profile Fields Optional
 
Hi Micheal,

I tried doing what you said here but for the lastname feild, but it doesnt work. I am using Moodle 1.9.5

Do you have any ideas please?

Thanks
 
Average of ratings: -
eu
Re: Making Required Profile Fields Optional
 
i just edit in:

editlib.php line 97

//$mform->addRule('lastname', $strrequired, 'required', null, 'client');


moodlelib.php line 2290

function user_not_fully_set_up($user) {
//or empty($user->lastname)
return ($user->username != 'guest' and (empty($user->firstname) or empty($user->email) or over_bounce_threshold($user)));
}


it's working, it doesn't redirect any more.
i'm using 1.9.4 moodle version

i wish this help you
sorry for my poorly english

regards
 
Average of ratings:Useful (2)
Picture of Max Yi
Re: Making Required Profile Fields Optional
 

thanks you very much. it's really a big help.

 
Average of ratings: -
Picture of Sonam Jamtsho
Re: Making Required Profile Fields Optional
 

Are you sure it worked. I tried the same way you did ,it didn't work for me.  Is there any other files that i need to edit to make it work.

regards

 
Average of ratings: -
Picture of John Isner
Re: Making Required Profile Fields Optional
 
This issue has a flip side: some of us want to make optional fields mandatory. See this discussion.


 
Average of ratings: -