Allow users to assign themselves a role system-wide?

Allow users to assign themselves a role system-wide?

by Adam Bernstein -
Number of replies: 7

Hello,

I am looking for a way to allow certain users to assign themselves a custom role I've created in the system wide context.

For example, some content management systems allow for entry of an "RSVP code" or similar for users to add a role to their own account.

Is something similar available in Moodle, or is there another recommended way to achieve this? I know you can self-enrol in a course, but I'm not sure about adding a role system-wide.

We are using Moodle 2.6.2. Thanks in advance!

Average of ratings: -
In reply to Adam Bernstein

Re: Allow users to assign themselves a role system-wide?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I guess if I was going to do this, I would develop this as a block plugin. https://docs.moodle.org/dev/Blocks

  1. If the user does not currently have the role, display a simple form in the block: a text input for typing in the RSVP code, with a submit button.
  2. When the form is submitted, verify the code, and either assign the role, or display an error.
  3. If the user already has the role, the block is invisible.
In reply to Adam Bernstein

Re: Allow users to assign themselves a role system-wide?

by ryan sanders -

system wide = enrolling user at front page,

you can enrol folks to different categories

and then you can enrol folks in per course.

In reply to Adam Bernstein

Re: Allow users to assign themselves a role system-wide?

by Adam Bernstein -

Thank you Tim and Ryan for these helpful replies.

Tim's idea of a block plugin makes sense to me.

Ryan's clarification regarding the system-wide context being the same as assignment on the front page also makes sense to me. However, are you suggesting that there may be an existing way for users to add a role to themselves in the front page course? That is, something like self-enrollment in the front page course, but for roles?

Thanks in advance.

In reply to Adam Bernstein

Re: Allow users to assign themselves a role system-wide?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Actually, system-wide is not the same is in the front page.

In reply to Tim Hunt

Re: Allow users to assign themselves a role system-wide?

by ryan sanders -

google keywords = moodle system wide role assignment

returned this... https://docs.moodle.org/28/en/Assign_roles

adjust the 28 to your moodle version might bring back something specific for your moodle version if not 2.8.x

example: https://docs.moodle.org/27/en/Assign_roles = 2.7.x version of moodle

In reply to ryan sanders

Re: Allow users to assign themselves a role system-wide?

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

Yes - what Tim says: system wide is not the same as on the front page and I don't think there is a simple standard way of users being able to assign themselves a role system wide.

In reply to Mary Cooch

Re: Allow users to assign themselves a role system-wide?

by Adam Bernstein -

Thanks very much to each of you for your replies. Very helpful.

It sounds like the approach Tim suggested is indeed the best way for most users. In our case, we will likely defer and manually enroll users in the system role for the time being, because in the long term we are planning to build a plugin to trigger the Moodle role assignment via an external system (our domain's main portal).