WordPress.org

Ready to get started?Download WordPress

Forums

Media submit hook? (4 posts)

  1. kenrik
    Member
    Posted 3 years ago #

    How would I call a function when a file is uploaded? I want to call my custom S3 upload.sh script when a new item is added to the uploads folder.

    Any help would be greatly appreciated!

  2. jocken
    Member
    Posted 3 years ago #

    add_action('add_attachment, 'YOUR_FUNCTION');
    http://codex.wordpress.org/Plugin_API/Action_Reference

  3. kenrik
    Member
    Posted 3 years ago #

    Hmm... that does not seem to be working.

    Actually I was not clear enough..

    I need to call this bit of PHP when a file is uploaded, deleted or edited.

    $output = shell_exec("bash ./upload.sh"); echo $output;

    I can't seem to find the right code to execute this when any of the above happen. Examples and help would be greatly appreciated.

    Thanks.

  4. jocken
    Member
    Posted 3 years ago #

    I would do it like this, have no idea if it works though, so consider that.

    add_action('add_attachment', 'my_shell_exec');
    add_action('edit_attachment', 'my_shell_exec');
    add_action('delete_attachment', 'my_shell_exec');
    
    function my_shell_exec(){
    $output = shell_exec("bash ./upload.sh");
    echo $output;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.