I have a custom post type called "Magazine" shown in the admin interface. Everytime a user uploads a file in the wp-admin to my custom post type "Magazine", I want to fire a hook because I have to process the file.

Is there any action hook I can use in this case?

Hope someone can help me.

  • do you want to resize image? – Arvind Pal Apr 18 '14 at 14:58
  • no I want to check if the uploaded file is a pdf which I want to send to a webservice. – pbaldauf Apr 19 '14 at 13:23

Try this way, should work well

function cpt_from_attachment($attachment_ID)
    global $current_user;

    $attachment_post = get_post( $attachment_ID );

    $type = get_post_mime_type($attachment_ID);


add_action("add_attachment", 'cpt_from_attachment');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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