Making Required Profile Fields Optional

Making Required Profile Fields Optional

by Kenneth Newquist -
Number of replies: 10
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: -
In reply to Kenneth Newquist

Re: Making Required Profile Fields Optional

by seaghan moriarty -
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!
In reply to seaghan moriarty

Re: Making Required Profile Fields Optional

by Joe Murphy -
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.
In reply to Joe Murphy

Re: Making Required Profile Fields Optional

by Michael | -
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.




In reply to Michael |

Re: Making Required Profile Fields Optional

by Ian Scott -
You will also need to do this in the file edit_form.php if you want the Description field not to be compulsory.
In reply to Ian Scott

Re: Making Required Profile Fields Optional

by Zoe Bogner -
Thanks Ian, you just saved me a lot of time!

Why isn't that line in editlib.php with all the others?
In reply to Michael |

Re: Making Required Profile Fields Optional

by Zak Fleming -
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
In reply to Zak Fleming

Re: Making Required Profile Fields Optional

by Mario Guarinoni -
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)
In reply to Mario Guarinoni

Re: Making Required Profile Fields Optional

by Max Yi -

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

In reply to Mario Guarinoni

Re: Making Required Profile Fields Optional

by Sonam Jamtsho -

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