Action Hooks

This document lists all available action hooks in Advanced Media Offloader. Action hooks allow you to execute custom code at specific points during the plugin’s execution.

Upload Actions

advmo_before_upload_to_cloud

Fires before an attachment is uploaded to cloud storage.

Parameters:

  • $attachment_id (int) – The attachment ID being uploaded

Example:

add_action('advmo_before_upload_to_cloud', function($attachment_id) {
    error_log('Uploading attachment: ' . $attachment_id);
});

advmo_after_upload_to_cloud

Fires after an attachment has been successfully uploaded to cloud storage.

Parameters:

  • $attachment_id (int) – The attachment ID that was uploaded

Example:

add_action('advmo_after_upload_to_cloud', function($attachment_id) {
    // Send notification or update external system
    update_post_meta($attachment_id, 'cloud_uploaded_at', time());
});

File Deletion Actions

advmo_before_delete_local_file

Fires before local file(s) associated with an attachment are deleted.

Parameters:

  • $attachment_id (int) – The attachment ID
  • $deleteLocalRule (int) – The retention policy:
    • 1 – Smart Local Cleanup (delete only sized images, keep original)
    • 2 – Full Cloud Migration (delete all local files including original)

Example:

add_action('advmo_before_delete_local_file', function($attachment_id, $deleteLocalRule) {
    $file = get_attached_file($attachment_id);
    error_log('Deleting local file: ' . $file . ' (Rule: ' . $deleteLocalRule . ')');
});

advmo_after_delete_local_file

Fires after local file(s) associated with an attachment have been deleted.

Parameters:

  • $attachment_id (int) – The attachment ID
  • $deleteLocalRule (int) – The retention policy applied

Example:

add_action('advmo_after_delete_local_file', function($attachment_id, $deleteLocalRule) {
    // Log cleanup completion
    update_post_meta($attachment_id, 'local_cleanup_completed', time());
});

advmo_before_delete_regenerated_local_thumbnails

Fires before regenerated thumbnail files are deleted locally.

Parameters:

  • $attachment_id (int) – The attachment ID
  • $thumbnails_to_upload (array) – Array of thumbnails that were uploaded
  • $deleteLocalRule (int) – The retention policy

Example:

add_action('advmo_before_delete_regenerated_local_thumbnails', function($attachment_id, $thumbnails_to_upload, $deleteLocalRule) {
    foreach ($thumbnails_to_upload as $thumbnail) {
        error_log('Deleting regenerated thumbnail: ' . $thumbnail['data']['file']);
    }
});

advmo_after_delete_regenerated_local_thumbnails

Fires after regenerated thumbnail files have been deleted locally.

Parameters:

  • $attachment_id (int) – The attachment ID
  • $thumbnails_to_upload (array) – Array of thumbnails that were uploaded
  • $deleteLocalRule (int) – The retention policy

Example:

add_action('advmo_after_delete_regenerated_local_thumbnails', function($attachment_id, $thumbnails_to_upload, $deleteLocalRule) {
    // Update cache or notify external system
});

Need More Help?

Can't find what you're looking for? We're here to help!

Contact Support