Redirect landing page to a plugin for specific roles

Redirect landing page to a plugin for specific roles

door Jeffrey Bannister -
Aantal antwoorden: 3

Hi All,

I'm struggling to find a solution to this problem.

I have created a new role for a user that logs in to view a custom report plugin I have developed. At the moment that user role logs in and gets a custom menu item on the left hand side which will take them to the plugin.

What I really want is that when the role logs in, they are automatically redirected to the plugin page.

Any suggestions on how to achieve this?

Thanks in advance,

Jeff

Gemiddelde van de beoordelingen:  -
Als antwoord op Jeffrey Bannister

Re: Redirect landing page to a plugin for specific roles

door David Mudrák -
Foto van Core developers Foto van Documentation writers Foto van Moodle HQ Foto van Particularly helpful Moodlers Foto van Peer reviewers Foto van Plugin developers Foto van Plugins guardians Foto van Testers Foto van Translators

Given that you already have a custom report in place, you can also try following:

  • Add an event observer into your report that listens to \core\event\user_loggedin event - see events API docs page for details.
  • In your observer, decide if the user is among those one you want to send to the report.
  • If so, set the $SESSION->wantsurl to point to your report URL.

So then when a user logs in, the complete_user_login() is called which should trigger your observer. After that, the core_login_get_return_url() should return the value that your observer injected there. See login/index.php for where and how these functions are called.

Gemiddelde van de beoordelingen: Useful (1)