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

apply_filters_ref_array( 'vikappointments_before_rename_media', bool $rename, string &$new, string $prev, JModel $model )

Fires before renaming a media file.


Description

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

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('Invalid name', 500);
// or register the error
$model->setError('Invalid name');
return false;

Parameters

$rename

(bool)  Use false to abort the renaming process.

&$new

(string)  The new file name.

$prev

(string)  The current file name.

$model

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


Example

/**
 * Trigger event to allow the plugins to make something before
 * renaming one or more media files.
 *
 * @param  boolean  $rename  False to abort the saving process.
 * @param  string   &$new    The new file name.
 * @param  string   $prev    The current file name.
 * @param  JModel   $model   The model instance.
 */
add_filter('vikappointments_before_rename_media', function($rename, &$new, $prev, $model)
{
    /**
     * @todo do something before renaming the media file
     */

    return $rename;
}, 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.