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.

For more advanced bulk member update or import features, see our Import Users from CSV Add On.

Banner for Advanced Code Recipe Tutorial for Paid Memberships Pro

The Code Recipe

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.

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.

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.

Featured Image for Membership Site Development Course: The Basics
Was this article helpful?
YesNo