Programmatically changing a user's group

Permalink
Hi, is there a way to automate changing a user's group? For instance, let's say there are two groups, Customers and Guests. Suppose a customer's subscription is over, I want the user's group changed back to guest in order to restrict access to store content. How can I pull this off? Thanks.

 
clint15 replied on at Permalink Reply
Never mind. Solved it using mySQL. Used php to query the user's subscription on the database. Depending on the subscription status, I would programmatically change the user's group using either;
if (!$u->inGroup($g)) {
    $u->enterGroup($g);
}

or
if ($u->inGroup($gr)) {
    $u->exitGroup($g);
}