Skip to content

Instantly share code, notes, and snippets.

@dmmoelle
Created December 23, 2017 02:52
Show Gist options
  • Save dmmoelle/0d5bf6629afc556311d80f5f816ea368 to your computer and use it in GitHub Desktop.
Save dmmoelle/0d5bf6629afc556311d80f5f816ea368 to your computer and use it in GitHub Desktop.
SELECT
o.user_id,
o.timestamp,
(select user_login from wp_users where id = o.user_id limit 1) as user_login,
(select user_email from wp_users where id = o.user_id limit 1) as user_email,
(select name from wp_pmpro_membership_levels where id = o.membership_id limit 1) as level,
o.total,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'last_name' limit 1) as last_name,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'first_name' limit 1) as first_name,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'pmpro_saddress1' limit 1) as address,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'pmpro_scity' limit 1) as city,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'pmpro_sstate' limit 1) as state,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'pmpro_szipcode' limit 1) as zip,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'dob' limit 1) as dob,
(select meta_value from wp_usermeta where user_id = o.user_id and meta_key = 'phone' limit 1) as phone
FROM wp_pmpro_membership_orders o
WHERE o.status = 'success';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment