Auto subscribe user to sub2 after expiration of sub1

Hi there,

I have 1 free sub and 1 premium sub.
The free sub is auto-added to every user, when he registers. If he pays for premium, he's signed up for the premium sub. At this time, he loses his free sub (that's not, what I intended in the beginning, but it's okay).

My Problem: When the premium sub expires, the user no longer has any subscription and therefore none of the attached access-levels. It's no option to put two access-levels into the premium sub.

Is it somehow possible to auto-sign a user to the free sub, after he loses the premium sub?

Maybe you can simply give me some lines of php code, I can put into the functions.php (logic: if user is logged in and has no sub, then assign to the sub, that he get's, when he registers)

Thank you!