I am trying to create a new user within the woocommerce_order_status_completed
hook.
add_action( 'woocommerce_order_status_completed', 'custom_woocommerce_order_status_completed', 10, 1 );
function custom_woocommerce_order_status_completed( $order_id )
{
$password = wp_generate_password( 16, true );
$user_id = wp_create_user( 'usertest@gmail.com', $password, 'usertest@gmail.com' );
}
$user_id
returns an actual ID. It appears to create the user but when i look at the backend the user is not there. I even check the database for the user id and it's not there.
If i call the same function on the action woocommerce_after_register_post_type
it creates the user.
Any idea what could be causing this issue?