0

I tried to remove action added by a plugin only for specific posts.

But I can't find the hook to get the page ID currently edited (wp-admin/post.php?post=112) and add action conditionnally.

Here's the code :

// Deactivate plugin Resize at Upload Plus on page id=112
remove_action('wp_handle_upload', 'hz_uploadresize_resize');
add_action('wp_loaded','custom_upload_resize');
function custom_upload_resize(){
    $id = get_the_ID();
    if (isset($id) && $id !== 112){
        add_action('wp_handle_upload', 'hz_uploadresize_resize');
    }
}

The plugin resizes images after uploading http://wordpress.org/plugins/resize-at-upload-plus/

Can you help please ?

  • 1
    Just a guess but thinking $id !=='112'` is too strict a comparison. Won't $id be an integer, and not a string? Either lose a = or lose the apostrophies '' – GhostToast Feb 13 '14 at 20:22
2

wp_loaded hook is too early for environment to be completed and for conditionals to work.

You need to do this a little later, for example on admin_head hook.

PS also use get_the_ID() for cleaner look :)

  • Thanks, it helps. But any condition is ignored. I still find a solution :) – Céline Garel Feb 13 '14 at 22:43

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.