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.

Table of contents
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.
Customizations
Update line 16 and line 23 if you are using a database prefix other than the default wp_
.
Update line 19 with your membership level ID. Navigate to Memberships > Settings > Levels to identify your membership level ID numbers.
Update line 21 and line 22 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 22 to just ” or NULL
.