:)

I'm using wordpress with woocommerce, and I would like to automate the following step. When an order is completed, I would like to change the user role associated with that order id from 'customer' to 'subscriber'.



By searching around, I think I should be able to accomplish this by using a hook in functions.php:

add_action( 'woocommerce_order_status_completed', 'change_role_from_customer_to_subscriber' );


Then add the function:

function change_role_from_customer_to_subscriber($order_id){
// code to change role to subscriber
}


In the code, I think I need to do 2 things:
1) get the user id that is associated with that order id
2) change role of that user id to subscriber



I've tried a lot, but I couldn't get it to work (neither getting the right user id, nor changing the role of a user id). So any help would be appreciated! I've seen 2 related questions asked before on stack overflow, but unfortunately the answers there did not work for me. I hope someone can help me out!

Thanks a lot! :)


Edit:
Someone helped me out with the second part of the problem, so that's great news for me :)

Unfortunately, I still haven't figured out the first part: how to get the user id that is associated with the order id.
Any ideas?


Question: I want to travel to the USA while working remotely for my non-US employer
Answer: Tourist visas do not allow you to work as employed in the issuing country. But, they do not prohibit you from doing your 'home' work while on vacation.

So anyone from anywhere who is working on their laptop or smartphone while on short or long vacation is not under any penalty.

You can do your work/ personal stuff there, as long as your employment i.e. employer-employee relationship has no direct legal, financial bindings with the destination country of tourism.

PS: For all technical purposes, you are not going to work in the US, even if you are remotely working for your German employer. It is stupid for you to mention that. Why? 

What is your intended relationship with US/ US Consulate/ US Visa - as a tourist.. right..? 

Whether you go there and check your Germany work email or do some presentations remotely for your Germany company or take up a dance class for a few weekends, it is outside of the domain of your relationship with the US.