List All Active Members

I am using the Membership plugin.

I am trying to create a page which list all members on the website. I am using Members-List plugin:
http://wordpress.org/extend/plugins/members-list/

(This appears similar to the Members-Directory Plugin:
https://premium.wpmudev.org/project/members-directory)

The problem is that Members-list is listing ALL users on the website - both active and inactive. The Membership plugin creates inactive members if someone doesn't pay for their account or if the membership expires, etc.

I need to be able to list active members only. Has anyone found a solution for this?

How Membership Plugin Stores Active/Inactive information:

In the wp_usermeta database table, there are the following fields:
umeta_id, user_id (the id of the user), meta_key and meta_value.

For example,

INSERT INTO 'wp_usermeta' VALUES (10, 1, 'wp_membership_active', 'yes');

This would mean the admin user (user_id = 1) has a wp_membership_active status set to yes.

Before the Members List plugin displays the users, we need to check the wp_usermeta table to see if wp_membership_active is set to yes for each user. I am not an SQL expert so I could use some assistance/guidance here please.

Thanks for your help.

  • Mason
    • DEV MAN’s Sidekick

    Hiya targetd,

    It looks like you're heading in the right direction with this. I don't have the code right at the moment, and am headed out for the holiday, but I'll ask a couple developers to look at this as well and we'll get back to you with some further information.

    Thanks!

  • S H Mohanjith
    • Developer

    You don't need to run queries directly on the wp_usermeta table directly. WordPress provides four convenience functions you could use, get_usermeta, update_usermeta, add_usermeta, delete_usermeta.

    To determine whether a user is an active member by checking whether get_usermeta( $user->ID, 'wp_membership_active'); is 'yes' .

    You can add the following code to members-list/class/members.php line 72 to remove non active users (i.e. list only active users).
    $active = get_usermeta( $this->ID, $this->db->prefix . 'membership_active');
    if (!(empty($active) || $active == 'yes')) {
    continue;
    }

    Hope this helps :slight_smile:

  • targetd
    • Site Builder, Child of Zeus

    Hi drmike,

    Thanks for the info. I can list active users using S H Mohanjith's suggestion, but I am not sure the correct way to use cache.

    Could you please modify S H Mohanjith's example to correcting use cache?

    Many thanks for your assistance.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.