Any way around user logout to activate new role for user?

Any way around user logout to activate new role for user?

by Richard French -
Number of replies: 3

I've read in several places that if a user is assigned a new role and user is currently logged in, they have to logout and login back in to activate their new role assignment. Question - Is there any way around this?

Background - I'm capturing the user_loggedin event and if the user does not have the proper role assignment, I assign them the role (which works perfectly by the way). The problem is...well, they are in the process of logging in already. Now they have to logout and log back in to have access to the proper site content. Can I, via PHP, log them out "under the covers" and start the login process again without the user being the wiser?

Thanks for any and all ideas...

Richard

Average of ratings: -
In reply to Richard French

Re: Any way around user logout to activate new role for user?

by Darko Miletić -

Afaik what you describe is moodle 1.x behavor. In Moodle 2.x page reload will sufice. So just do redirect tp home page after role assign.

Average of ratings: Useful (1)
In reply to Darko Miletić

Re: Any way around user logout to activate new role for user?

by Richard French -

Darko,

Thanks for the quick response. Unfortunately I have very little experience with page redirects. Could you point me to an example? Thanks...

Richard

In reply to Richard French

Re: Any way around user logout to activate new role for user?

by Darko Miletić -

redirect('/relative/url/location');

For example to redirect to frontpage you will do:

redirect('/');