Last active
April 13, 2021 03:06
-
-
Save strangerstudios/60cdb6bd6b31c19f6eace43c8f7503b1 to your computer and use it in GitHub Desktop.
SQL query to give all non-member WP users level 1 with a specific start and end date set.
This file contains hidden or 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
#give all non-member WP users level 1 with a specific start and end date set | |
#change the level (1) below and start (2017-01-01) and end (2017-12-31) dates below to per your needs | |
INSERT INTO wp_pmpro_memberships_users (user_id, membership_id, status, startdate, enddate) | |
SELECT | |
u.ID, #ID from wp_users table | |
1, #id of the level to give users | |
'active', #status to give users | |
'2017-01-01', #start date in YYYY-MM-DD format | |
'2017-12-31' #end date in YYYY-MM-DD format, use '' for auto-recurring/no end date | |
FROM wp_users u | |
LEFT JOIN wp_pmpro_memberships_users mu | |
ON u.ID = mu.user_id | |
AND status = 'active' | |
WHERE mu.id IS NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post on "Database Script: Apply a membership level to all users without a level" at Paid Memberships Pro here: https://www.paidmembershipspro.com/database-script-apply-membership-level-users-without-level/