0

I have a scenario where a wp admin wants an external application to listen and detect when a pdf has been uploaded to a directory within wordpress.

Ex: a new terms and condition (T&C) document is created and the WP. The site admin upload this file to the sites T&C directory.

When the admin uploads this pdf is there any event emitted that an external application could have a webhook listening to pick up the addition/upload of the new file.

1 Answer 1

2

Use the action add_attachment, and look at the MIME type, then do whatever you need:

add_action( 'add_attachment', function( $post_id ) {
    
    if ( 'application/pdf' !== get_post_mime_type( $post_id ) ) {
        return;
    }
    
    // Here you can update a static file, send a HTTP 
    // request to the other site or send an email.
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.