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.
<?php
$_LW->REGISTERED_APPS['my_app']=[
'title'=>'My App',
'handlers'=>['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 = [
'room_number' => @$_LW->_POST['room_number'],
'event_sponsor' => @$_LW->_POST['event_sponsor']
];
$_LW->setCustomFields($data_type, $last_id, $custom_fields, []);
}
};
}
}
?>