English (United Kingdom)
Knowledge Base  >  Vik Appointments  >  Hooks  >  Media  >  Before Delete

apply_filters( 'vikappointments_before_delete_media', bool $delete, mixed $id, mixed $path, JModel $model )

Fires before deleting a media file.


Description

Trigger hook to allow the plugins to make something before deleting one or more media files.

TIP: in case of failure while deleting the record, it is possible to throw an exception to abort the deleting 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('You are not authorised', 403);
// or register the error
$model->setError('You are not authorised');
return false;

Parameters

$delete

(bool)  Use false to abort the deleting process.

$id

(array|string)  Either the file name or an array of files to delete.

$path

(string|null)  An optional path from which the file should be deleted. If not specified, the default media folder will be used.

$model

(JModel)  The model instance that handles the deleting process.


Example

/**
 * Trigger hook to allow the plugins to make something before
 * deleting one or more media files.
 *
 * @param  boolean  $delete  False to abort the saving process.
 * @param  mixed    $id      Either the record ID or a list of records.
 * @param  mixed    $path    An optional path from which the file should be deleted.
 * @param  JModel   $model   The model instance.
 */
add_filter('vikappointments_before_delete_media', function($delete, $id, $path, $model)
{
    /**
     * @todo do something before deleting the media file
     */

    return $delete;
}, 10, 4);

Changelog

Version Description
1.2 Introduced.
Last Update: 2021-08-08
Helpful?
See Also:

This website uses cookies

This website uses cookies and similar technologies. Some of these technologies are necessary for the proper functioning of the website (Essential). Other technologies are used to evaluate user behavior (Analysis), to integrate external media or for advertising purposes. If you agree, these technologies are activated. For details, please refer to the privacy policy. From this same page you can also update/revoke your consent. If you do not give your consent, only cookies with essential functions will be activated.

We use technologies from the USA on our website. If you give your consent, you therefore consent at the same time to your data being transferred to the USA. We would like to point out that the USA does not have a level of data protection comparable to that of the EU and that any US company can be obliged by state authorities to hand over your data without you having any effective legal protection against this.