This already exists. It was created and supported here by @simon. It works well with Paid Memberships Pro.