title: WooCommerce hook for order creation from admin
body: <p>In my custom plugin (working in WooCommerce 2.6.x and 3.x), I need to get the order ID when a new order is created. I tried different hooks but they work only when the customer creates an order and not when an order is created from admin.</p>
  
  <p>I tried:</p>
  
  <ul>
  <li>woocommerce_new_order</li>
  <li>woocommerce_thankyou</li>
  <li>woocommerce_checkout_order_processed</li>
  <li>woocommerce_checkout_update_order_meta</li>
  </ul>
  
  <p><strong>Update</strong></p>
  
  <p>Finally I used this:</p>
  
  <pre><code>add_action('wp_insert_post', function($order_id)
  {
      if(!did_action('woocommerce_checkout_order_processed') 
          &amp;&amp; get_post_type($order_id) == 'shop_order'
          &amp;&amp; validate_order($order_id))
      {
           order_action($order_id);
      }
  });
  </code></pre>
  
  <p>where <em>validate_order</em> is:</p>
  
  <pre><code>function validate_order($order_id)
  {
      $order = new \WC_Order($order_id);
      $user_meta = get_user_meta($order-&gt;get_user_id());
      if($user_meta)
          return true;
      return false;
  }
  </code></pre>
  
  <p>Thanks to <em>validate_order</em> the action isn't executed when you start to create the order. I use <code>!did_action('woocommerce_checkout_order_processed')</code> because I don't want that the action is executed if the order is created by a customer (I have a specific action for that, using <code>woocommerce_checkout_order_processed</code>).</p>