Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save onwp/adca71c72fb149dc39dc03844f55e583 to your computer and use it in GitHub Desktop.
Save onwp/adca71c72fb149dc39dc03844f55e583 to your computer and use it in GitHub Desktop.
Inactive LearnDash user SQL query
SELECT u.user_email,
um.meta_key AS "login_type",
from_unixtime(um.meta_value,'%c/%e/%y') AS "login_date",
GROUP_CONCAT(p.post_title) AS "courses"
FROM nPJeAgtL_users u
INNER JOIN nPJeAgtL_usermeta um ON um.user_id = u.id AND um.meta_key = 'learndash-last-login'
LEFT JOIN nPJeAgtL_learndash_user_activity lua ON lua.user_id = u.id AND lua.activity_type = 'course'
LEFT JOIN nPJeAgtL_posts p ON lua.course_id = p.id
WHERE from_unixtime(um.meta_value) < '2019-03-01 00:00:00' AND p.id IN (1947,1938,7694,1932)
GROUP BY u.user_login
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment