Handling the Moodle login event

Recall that when a user clicks on a link to a protected resource, Moodle calls loginpage_hook() in each enabled authentication plugin. To handle this, let us first implement loginpage_hook(). In Eclipse, add the following lines to auth.php:

 /**      * Will get called before the login page is shown.       *      */     function loginpage_hook() {                 $client_key = $this->config->client_key;         $client_secret = $this->config->client_secret;         $wordpress_host = $this->config->wordpress_host;                 if( (strlen($wordpress_host) > 0) && (strlen($client_key) > 0) && (strlen($client_secret) > 0) ) {             // kick ff the authentication process             $connection = new BasicOAuth($client_key, $client_secret);          // strip the trailing slashes from the end ...

Get Moodle 3.x Developer's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.