« All Handlers

onValidatePublicSubmission

The onValidatePublicSubmission handler is called when a public submission form has been submitted. A common usage is checking the $_LW->_POST values for required fields and populating the $_LW->REGISTERED_MESSAGES['failure'] array to return error message(s). See below for an example module.

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

class LiveWhaleApplicationMyApp {

public function onValidatePublicSubmission($data_type) { // when validating a public submission
global $_LW;
if ($data_type=='events') { // on submission of an event
if (empty($_LW->_POST['event_location'])) { // require location
$_LW->REGISTERED_MESSAGES['failure'][]='An event location must be specified.';
};
if (empty($_LW->_POST['event_types'])) { // require event type
$_LW->REGISTERED_MESSAGES['failure'][]='At least one event type must be specified.';
};
if (empty($_LW->_POST['event_description'])) { // require event description
$_LW->REGISTERED_MESSAGES['failure'][]='You must enter a description for your event.';
};
};
}

}
?>