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.

<?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.';
          };
      };
    }

   }
?>