How to get post ID with hooks publish_post, new_to_publish, etc

  1. Read the Codex,
  2. Look at the function in the core file,
  3. Modify your code as follows:

    function myFunc( $post ) {
    
        $postID = $post->ID;
    
    }
    

The post transistion does not send the post ID, it sends the complete post object. Sometimes a simple die(var_dump($postID)); (or whatever you use as parameter) helps to find out what will be send to the callback. If you don’t know how many parameters are send to the callback, put a die(var_dump(func_get_args())); at the first line of your callback.