• Resolved MYGM

    (@mygm)


    Hello,
    I am trying to figure out how to create a loop that will list all members within several specific membership levels. The current loop I have works for showing all members with certain meta keys/values however I need to add membership levels to the list. This is the loop I am using —

    <?php
    
    $blogusers = get_users (array(
            'meta_query'   =>
            array(
                    'relation' => 'AND',
    
                array(
                    'key' => 'custom_field_24'
                ),
    array(
                    'key' => 'custom_field_39',
    'value' => 'yes'
                ),
                array(
                    'key' => 'first_name'
                )
             )
       ));
    
                    foreach ($blogusers as $user) :
        ?>
    //my divs
    <?php endforeach; ?>

    And the loop that I think I need to use to access the membership levels, looks something like this —

    $member_ids = $wpdb->get_col("SELECT user_id FROM $wpdb->memberships_users WHERE membership_id = '1'");
    $level1users = get_users(array("include"=>$member_ids));

    http://ww.wp.xz.cn/extend/plugins/paid-memberships-pro/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi MYGM,

    This is beyond the scope of the basic plugin functions out of the box, but certainly doable.

    If you mean a front end directory listing of members, we’ve created custom listings like that in the past through our “Do It For Me” plan.

    Or because you seem to know what you are doing, you may wish to join our paid developer forums at http://www.paidmembershipspro.com/pricing.

    Thread Starter MYGM

    (@mygm)

    Hi,
    thanks for the response. I am working on figuring it out myself, but maybe any hints or tips to point me in the right direction can help.

    This is what I have so far, and it’s displaying users but it is displaying all users instead of those with the specified membership id —

    `<?php
    $member_ids = $wpdb->get_col(“SELECT user_id FROM $wpdb->memberships_users WHERE membership_id = ‘4’”);
    $level1users = get_users(array(“include”=>$member_ids));
    foreach($level1users as $user) : // start users’ profile “loop”
    ?><?php echo $user->user_email; ?> <?php
    endforeach; // end of the users’ profile ‘loop’
    ?>`

    What am I missing?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to create member directory loop’ is closed to new replies.