Skip to content

Commit

Permalink
MDL-61485 authentication: Add callback 'pre_signup_requests'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihail Geshoski authored and marinaglancy committed Feb 20, 2018
1 parent d1b4ca9 commit 4961e96
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion login/lib.php
Expand Up @@ -381,4 +381,16 @@ function core_login_validate_forgot_password_data($data) {
}

return $errors;
}
}

/**
* Plugins can create pre sign up requests.
*/
function core_login_pre_signup_requests() {
$callbacks = get_plugins_with_function('pre_signup_requests');
foreach ($callbacks as $type => $plugins) {
foreach ($plugins as $plugin => $pluginfunction) {
$pluginfunction();
}
}
}
5 changes: 5 additions & 0 deletions login/signup.php
Expand Up @@ -27,6 +27,7 @@
require('../config.php');
require_once($CFG->dirroot . '/user/editlib.php');
require_once($CFG->libdir . '/authlib.php');
require_once('lib.php');

if (!$authplugin = signup_is_enabled()) {
print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.');
Expand Down Expand Up @@ -59,6 +60,10 @@
exit;
}

// Plugins can create pre sign up requests.
// Can be used to force additional actions before sign up such as acceptance of policies, validations, etc.
core_login_pre_signup_requests();

$mform_signup = $authplugin->signup_form();

if ($mform_signup->is_cancelled()) {
Expand Down

0 comments on commit 4961e96

Please sign in to comment.