Commit 5d737aa5 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add local hooks for registration and user initialisation (bug #1001064)

Three new hooks are added:

local_init_user() - called after $USER is initialised.  This is useful
for changing the user's theme before $THEME is initialised.

local_register_submit() - called when the registration form is
successfully submitted, but before the submitted values are saved to
usr_registration.  This is useful for remembering the properties or
preferences of the logged-out user when the form was submitted.

local_post_register() - called after a user has successfully been
created and logged in during registration.  This is useful when
properties of the user (which may have been saved to usr_registration
by local_register_submit()) need to be transferred to the newly
registered user.

Change-Id: Ifcb19737bdcecb550185624f2fd78e541690a337
Signed-off-by: default avatarRichard Mansfield <>
parent c6a7c77b
......@@ -2150,6 +2150,10 @@ function auth_register_submit(Pieform $form, $values) {
$values['expiry'] = db_format_timestamp(time() + 86400);
if (function_exists('local_register_submit')) {
try {
if (!record_exists('usr_registration', 'email', $values['email'])) {
insert_record('usr_registration', $values);
......@@ -276,6 +276,10 @@ require_once('auth/lib.php');
$SESSION = Session::singleton();
$USER = new LiveUser();
if (function_exists('local_init_user')) {
// try to set the theme, or catch the thrown exception (eg if the name is invalid)
try {
$THEME = new Theme($USER);
......@@ -189,6 +189,10 @@ if (isset($key)) {
$USER = new LiveUser();
$USER->reanimate($user->id, $authinstance->id);
if (function_exists('local_post_register')) {
$SESSION->add_ok_msg(get_string('registrationcomplete', 'mahara', get_config('sitename')));
$SESSION->set('resetusername', true);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment