• Resolved Harry

    (@dibbyo456)


    Steps to reproduce:

    1) Turn on Remove Files From Server
    2) Now upload an image to wp.
    3) Now create a php file and use this this:

    require_once("wp-load.php");
    wp_delete_attachment(377, true);

    4) replace 377 with the uploaded attachment id.
    5) Run the script in PHP-CLI

    You MUST run it via PHP-CLI

    Results: The attachment won’t delete.

    Expected Results: Delete the attachment as well from the bucket.

    • This topic was modified 5 years, 8 months ago by Harry.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Harry

    (@dibbyo456)

    FYI: wp_delete_attachment() works fine when S3 Offload is not active.
    But if it’s active then wp_delete_attachment() does not work, specially when using external script in PHP CLI.

    • This reply was modified 5 years, 8 months ago by Harry.
    • This reply was modified 5 years, 8 months ago by Harry.
    Plugin Contributor ianmjones

    (@ianmjones)

    What’s the error?

    debug.log stack trace?

    Thread Starter Harry

    (@dibbyo456)

    Hello, sorry for the delay response.
    I actually traced back what was causing this issue.

    My theme has was actually disabling delete_attachment function via do_action if the user does not have enough permission.

    So, that’s why wp_delete_attachment was not working when using script through PHP-CLI because then the script did not have certain permission.

    Disabling the function resolved this issue. This ticket has nothing do with this plugin.

    Marking this ticket as resolved.

    Plugin Contributor ianmjones

    (@ianmjones)

    Thanks for letting us know, much appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Plugin breaking the wp_delete_attachment() functions’ is closed to new replies.