Restrict role updation after register

Restrict role updation after register

by Rajakumar Jillella -
Number of replies: 3

I'm using Moodle 3.0.


I have added extra field in signup form like Role with selection box.

The selection list is Teacher, Student.


Student registered in my website and enrolled with one course.

And that student updating his role as Teacher through his Editing Profile settings.




How do we restrict the role updating in Editing Profile Settings.


Thanks in Advance.


Average of ratings: -
In reply to Rajakumar Jillella

Re: Restrict role updation after register

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Sorry, not an answer - Just a question - what is the purpose of your additional field since it doesn't actually change the role of a student or teacher in an actual course? Is it for identifying them when the admin gives them an actual course role?
In reply to Mary Cooch

Re: Restrict role updation after register

by Rajakumar Jillella -

Hi Mary,


The purpose of additional field is to select the role while registering. Whether it is Student or Teacher.

If the user registered as a student through signup form, Defaultly he is able to update his role as Teacher in Editing Profile Settings after registration.


Have to restrict update the additional field role in Editing Profile Settings.


In reply to Rajakumar Jillella

Re: Restrict role updation after register

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

You really want to allow anyone who registers to choose for themselves whether they are a student or teacher?

I hope you have fully considered the security implications of that - people who are supposed to be students having access to gradebook and other students' results, being able to edit all the content etc etc...

Also, roles such as student or teacher are generally given within a course and not on a site-wide basis, which is what you would appear to be trying to do by setting them through a user profile, so not only would the self-proclaimed 'teacher' have access to course books and editing on the course you want them to enrol on, but potentially to every course on your site.

The easiest way to prevent a user editing it on the profile settings page would simply be to use css to hide it so they cant see it anyway. Other than that I suspect you are into some significant core code hacking as I am not aware of a way to make user profile fields appear as role dependent (unless someone can correct me on that and i can learn something new smile )