Search for Resources and Solutions

Delete Class

The files from the user's storage and the administrator's storage are deleting by using the class Delete. The Delete is located in the application/base/classes/media folder.

It's important to use this class in any app, component, plugin or theme to delete the media files, because in this way we can always customize the deletion based on our needs.

To use the Delete class in your files, you have to use this namespace:

use MidrubBase\Classes\Media as MidrubBaseClassesMedia;

And after, the deletion code looks like this:

(new MidrubBaseClassesMedia\Delete)->delete_file(array(

    'media_id' => $media_id


In my example above i'm using only the media_id for the file which should be deleted. But if the user is not logged in, there are required even these parameters:

  • user_id - contains the user's ID which owns the media.
  • role_id - contains the user's role. Should be provided because in this way will be executed the user's hook even for user's apps.

The array provided to the delete_file method, will be provided even to the hook

Was this article helpful?