This advanced code recipe contains a SQL script to run against your WordPress site’s database. You can use Adminer, phpMyAdmin, or your host’s MySQL management tool of choice to execute the query.
The script will apply a membership level (by ID) and expiration (optional) to all users in the wp_users table that do not already have a membership level. This is useful for sites that already have a large number of “users” that you would like to be placed into a default membership level or a grandfathered-in membership level from an older system.
Our PMPro Toolkit Add On includes a script under the Tools menu of your dashboard to give existing non-member users a membership level without having to write SQL queries yourself.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update line 3 and line 10 if you are using a database prefix other than the default ‘wp_’.
Update line 6 with your membership level ID.
Update line 8 and line 9 with the membership level start (any date in the past or today) and end dates respectively. The format for these values is YYYY-MM-DD.
For membership with no expiration date, change the second date on line 9 to just ” or NULL.
Author: Kim Coleman
Kim Coleman is the co-founder of Paid Memberships Pro, the most trusted membership platform, which powers over 90,000 membership sites worldwide. With over two decades of experience in development, management, and marketing, Kim plays a pivotal role in shaping the product and guiding the team.
She specializes in content creation, video tutorials, and frontend development for the core open-source plugin and its various Add Ons, helping businesses of all sizes build and grow their membership sites.
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.