The membership_expired
email template is sent when a user’s membership has expired (as long as their membership level had a set expiration period such as 1 year, or a set expiration date like 2023-01-01).
However, this only informs a user that their membership has expired and does not include any data related to the expired level.
This code recipe fetches the last expired membership level via SQL query and adds the level name as an email variable—which can be used to personalize the message.
The Code Recipe (PHP)
Adding the Recipe to Your Website
You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.
Free Course: Membership Site Development—The Basics
Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.