« All Handlers

onAfterPublicSubmission

The onAfterPublicSubmission handler is called after a public submission has been received, validated with no errors, and saved to your database. The $last_id field is the ID of that submission, which you can use for making additional changes, saving custom fields, etc. 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
26
27
28
<?php
$_LW->REGISTERED_APPS['my_app']=array(
'title'=>'My App',
'handlers'=>array('onAfterPublicSubmission'),
);

class LiveWhaleApplicationMyApp {

public function onAfterPublicSubmission($data_type, $last_id) {
global $_LW;
if ($data_type=='events') { // on submission of an event

// if room_number or event_sponsor fields were set, save those values
if (!empty($_LW->_POST['room_number']) || !empty($_LW->_POST['event_sponsor'])) {

$custom_fields = array(
'room_number' => @$_LW->_POST['room_number'],
'event_sponsor' => @$_LW->_POST['event_sponsor']
);
$_LW->setCustomFields($data_type, $last_id, $custom_fields, array());

}

};
}

}
?>