Assign members full role and not just capability

Do you have a snippet to assign members the role instead of capability upon registration and for existing members, and then having that role withdrawn when the member subscription ends.

Thanks