What’s a quick and dirty way to get “lapsed” members in WordPress configured with s2Member?

I have a default installation of WordPress configured with the membership management plugin known as s2Member. What is a quick and dirty way to return an array of “lapsed” members?

I assume this information is hidden somewhere in the user’s metadata.

Related posts

Leave a Reply

1 comment

  1. You can search for the “demoted” note that s2Member logs:

    $lapsedMembers = $wpdb->get_results(
        $wpdb->prepare("
            SELECT
                DISTINCT (`u`.`ID`),
                `u`.`display_name`    `name`,
                `u`.`user_email`      `memberemail`,
                `u`.`user_registered` `enrollmentdate`,
                `um`.`meta_value`     `lapsereason`
            FROM
                {$wpdb->users} u
                LEFT JOIN {$wpdb->usermeta} um ON u.ID = um.user_id
            WHERE
                um.meta_key = %s
                AND um.meta_value LIKE % s
        ", 'wp_s2member_notes', '%Demoted%'),
        ARRAY_A
    );