I've a members' only subscription site, where the member can only have one active subscription, and I need to be able to get the status of the subscription.
I've been through all the documentation and found the
wcs_get_users_subscriptions() function, which returns an array of all subscription products for the given user, in reverse date order (ie, latest is always first).
I settled on this code which, whilst it works, I know is absolutely the wrong way to do it:
$subs = wcs_get_users_subscriptions( $user_id ); $subs = (object) array_shift( $subs ); $subs = (object) $subs->data; $return = $subs->status;
Does anyone know the right way?