title: Automatically create an user account after WooCommerce checkout and auto login
body: <p>The goal here is to automatically create a customer account directly after checkout and auto login.</p>
  <p>This is the code I am using:</p>
  <pre class="lang-php prettyprint-override"><code>add_action( 'woocommerce_thankyou', 'add_as_customer_after_checkout', 100, 1 );
  function add_as_customer_after_checkout( $order_id ) {
  
      $order = new WC_Order($order_id);
  
      $user = $order-&gt;get_user();
  
          if ( false != $user &amp;&amp; !user_can($user, 'administrator') ) {
          
              $role = 'customer';
          
              $user-&gt;add_role($role);
      }
  }
  </code></pre>
  <hr />
  <p>This has no error messages, but the user account is not created either. Any advice?</p>