Created
September 17, 2020 18:46
-
-
Save ronalfy/1c70899ca337bca74b0cf2374022582e to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Set Start and End Dates
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
/** | |
* Show SQL query examples for setting a start and end date for users without one. | |
* | |
* PLEASE BACK UP YOUR DATABASE FIRST BEFORE ATTEMPTING ANY OF THESE QUERIES | |
*/ | |
/* Get users with no end date - Useful for checking how many there are */ | |
select * from wp_pmpro_memberships_users where enddate is NULL OR enddate = '0000-00-00 00:00:00' | |
/* Get users with no start date - Useful for checking how many there are */ | |
select * from wp_pmpro_memberships_users where startdate is NULL OR startdate = '0000-00-00 00:00:00' | |
/* Set start date as same time as user registration */ | |
UPDATE wp_pmpro_memberships_users mu | |
LEFT JOIN wp_users u ON mu.user_id = u.ID | |
SET mu.startdate = u.user_registered | |
WHERE mu.startdate IS NULL | |
/* Set end date to arbitrary date */ | |
UPDATE wp_pmpro_memberships_users | |
SET enddate = '2020-01-01 00:00:00' | |
WHERE status = 'active' | |
AND ( enddate IS NULL | |
OR CAST(enddate AS CHAR(20)) = '0000-00-00 00:00:00' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment