Your cart is empty!
Before Save
apply_filters_ref_array( 'vikappointments_before_save_media', bool $save, mixed &$data, JModel $model )
Fires before saving/uploading a media file.
Description
Trigger hook to allow the plugins to bind the object that is going to be saved.
TIP: in case of failure while saving the record, it is possible to throw an exception to abort the saving process and return a readable error message. The same can be accomplished by registering an error to the model and returning false
.
// throw an exception
throw new Exception('Missing required field', 404);
// or register the error
$model->setError('Missing required field');
return false;
Parameters
- $save
-
(bool) Use false to abort the saving process.
- &$data
-
(array|object) Either an array or an object specifying the media properties to bind.
- $model
-
(JModel) The model instance that handles the saving process.
Example
/**
* Trigger hook to allow the plugins to bind the object that
* is going to be saved.
*
* @param boolean $save False to abort the saving process.
* @param mixed &$data The array/object to bind.
* @param JModel $model The model instance.
*/
add_filter('vikappointments_before_save_media', function($save, $data, $model)
{
/**
* @todo do something before saving/uploading the media file
*/
return $save;
}, 10, 3);
Changelog
Version | Description |
---|---|
1.2 | Introduced. |
Last Update: 2021-08-08
Helpful?