Directory

SELECT SQL_CALC_FOUND_ROWS u.ID, u.user_login, u.user_email, u.user_nicename, u.display_name, UNIX_TIMESTAMP(u.user_registered) as joindate, mu.membership_id, mu.initial_payment, mu.billing_amount, mu.cycle_period, mu.cycle_number, mu.billing_limit, mu.trial_amount, mu.trial_limit, UNIX_TIMESTAMP(mu.startdate) as startdate, UNIX_TIMESTAMP(mu.enddate) as enddate, m.name as membership, umf.meta_value as first_name, uml.meta_value as last_name FROM wordbase_users u LEFT JOIN wordbase_usermeta umh ON umh.meta_key = 'pmpromd_hide_directory' AND u.ID = umh.user_id LEFT JOIN wordbase_usermeta umf ON umf.meta_key = 'first_name' AND u.ID = umf.user_id LEFT JOIN wordbase_usermeta uml ON uml.meta_key = 'last_name' AND u.ID = uml.user_id LEFT JOIN wordbase_pmpro_memberships_users mu ON u.ID = mu.user_id AND mu.id = (SELECT id FROM wordbase_pmpro_memberships_users WHERE user_id = u.ID ORDER BY id desc limit 1) LEFT JOIN wordbase_pmpro_membership_levels m ON mu.membership_id = m.id WHERE (mu.enddate >= DATE_SUB(curdate(), INTERVAL 3 MONTH)) AND (umh.meta_value IS NULL OR umh.meta_value <> '1') AND mu.membership_id > 0 ORDER BY u.display_name ASC LIMIT 0, 16