- This topic has 1 reply, 2 voices, and was last updated 10 years ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Support site for Tips and Tricks HQ premium products
by
Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember Tweaks › How to get members by level id
Tagged: members, wp membership
Hi,
I was looking at the tweaks posted in https://www.tipsandtricks-hq.com/wordpress-membership/wp-emember-miscellaneous-tweaks-248 but can’t find my answer.
How can I get all members that are part of a specific LEVEL ID?
something like wp_member_get_members_by_level(LEVEL_ID) which would return an array of member objects or an array of member ids.
Help is appreciated. Thanks!
Here is an example snippet of code that will retrieve all members from a particular level:
$level = "2";//Membership Level ID in question
global $wpdb;
$sql = $wpdb->prepare("SELECT member_id from " . WP_EMEMBER_MEMBERS_TABLE_NAME . " WHERE membership_level=%d", $level);
$members = $wpdb->get_results($sql);