• Resolved jduffell

    (@jduffell)


    0
    down vote
    favorite
    I’m using PMPro to allow users to select a membership option, I can output using the following code the membership a user has, is there a way of combining this with wp_user_query in order to display users who have a membership. I’m fine with querying the user meta but with these values being stored in an alternate table I’m struggling to figure out how I go about this.

    Thanks for any help

    if(is_user_logged_in() && function_exists(‘pmpro_hasMembershipLevel’) && pmpro_hasMembershipLevel())
    {
    global $current_user;
    $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
    echo ‘Membership Level: ‘ . $current_user->membership_level->name;
    }

Viewing 1 replies (of 1 total)
  • Plugin Author Andrew Lima

    (@andrewza)

    Hi there,

    Thank you for using Paid Memberships Pro.

    Unfortunately you cannot use WP_Query to query custom database fields that Paid Memberships Pro uses, you may need to either write custom SQL or use the above example and join it to your current code by passing in each user’s ID to get the membership level – I think a custom SQL query may be quicker than the other solution.

    Here is a rough SQL query you can use to query data – https://gist.github.com/andrewlimaza/794f6fd24b05cb6b0bde33610ff20a2a

    I hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘WP_USER_QUERY meta query secondary table’ is closed to new replies.