« All Handlers

onLoad

The onLoad handler is commonly used for simple customizations that involve redirecting users (say, to login when custom criteria are met) or defining variables that will be used later in the page.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
$_LW->REGISTERED_APPS['my_app']=[
'title'=>'My App',
'handlers'=>['onOutput'],
];

class LiveWhaleApplicationMyApp {

public function onLoad() {
global $_LW;

// Require authentication on public submissions page
if ($_LW->page=='/submit/index.php') { // if on public submissions page
if (!$_LW->isLiveWhaleUser() && !$_LW->isSSOAuthOnlyUser()) { // require authentication
die(header('Location: /livewhale/?login&url=/submit/'));
};
};

}

}
?>