Created
January 5, 2024 21:49
-
-
Save MaximilianoRicoTabo/b2f91254bd8f12f9948e7578845bae59 to your computer and use it in GitHub Desktop.
Give all non members WP Users a level based on its role.
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 (2024-01-01) and end (2024-12-31) dates below and um.meta_value ('%subscriber%') to per your needs | |
INSERT INTO wp_pmpro_memberships_users (user_id, membership_id, code_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit,trial_amount,trial_limit, status, startdate, enddate) | |
SELECT | |
u.ID, # ID from wp_users table | |
1, # id of the level to give users | |
0, # code id to give users | |
0, # initial payment to give users | |
0, # recurring amount to give users | |
0, # number of cycles to bill users for | |
'Year', # period for each cycle | |
0, # total number of billings to do | |
0, # trial amount to bill users | |
0, # number of trial periods to bill users for | |
'active', # status to give users | |
'2024-01-01', # start date in YYYY-MM-DD format | |
'2024-12-31' # end date in YYYY-MM-DD format, use '' for auto-recurring/no end date | |
FROM wp_users u | |
INNER JOIN wp_usermeta um | |
ON u.ID = um.user_id | |
AND um.meta_key = 'wp_capabilities' | |
AND um.meta_value LIKE '%subscriber%' | |
LEFT JOIN wp_pmpro_memberships_users mu | |
ON u.ID = mu.user_id | |
AND mu.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