0

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.

2
  • do you want to resize image?
    – Arvind Pal
    Apr 18, 2014 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, 2014 at 13:23

1 Answer 1

1

Try this way, should work well

function cpt_from_attachment($attachment_ID)
    {          
    global $current_user;
    get_currentuserinfo();

    $attachment_post = get_post( $attachment_ID );

    $type = get_post_mime_type($attachment_ID);

    // DO WHAT YOU NEED
}

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.