Forum Replies Created
-
Guys can you help me out with this one. I tried all your methods and it is still showing all members if non selected.
Thanks
Anyone ?
Any Help ?
I am back to start. If there id’s it shows only specific ids but if its null then it shows all the users :s
<?php $contrytoggle = get_field( "country_toggle" ); $contrypri = get_field( "select_country" ); ?> <?php echo $contrytoggle; ?> <?php $custom_ids = my_custom_ids($contrytoggle, $contrypri); // $has_members_args = array( // 'include' => $custom_ids, // ); echo $custom_ids; // it echo no id and still it shows all the users if ( bp_has_members( $custom_ids ) ) : ?> <ul> <?php while ( bp_members() ) : bp_the_member(); ?> <li> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a> </div> <div class="item"> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a> </div> </li> <?php endwhile; ?> </ul> <?php else: ?> <div id="message" class="info"> <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p> </div> <?php endif; ?> </div>
If I pass include inside if then,
echo $contrytoggle; = It shows 4 id’s 6,7,8,9
and below code show only 3 users… user with 6th ID is missing
<?php $contrytoggle = get_field( "country_toggle" ); $contrypri = get_field( "select_country" ); ?> <?php echo $contrytoggle; ?> <?php $custom_ids = my_custom_ids($contrytoggle, $contrypri); // $has_members_args = array( // 'include' => $custom_ids, // ); echo $custom_ids; if ( bp_has_members( 'include=' . $custom_ids ) ) : ?> <ul> <?php while ( bp_members() ) : bp_the_member(); ?> <li> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a> </div> <div class="item"> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a> </div> </li> <?php endwhile; ?> </ul> <?php else: ?> <div id="message" class="info"> <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p> </div> <?php endif; ?> </div>
Hi,
Thanks Boone for replying.
I did as you said but still this while loop shows all the user profiles.
If I echo ” echo $custom_ids; ” This shows correct number of ids
Is there something I need to do with while loop as well ?
Thanks
<?php $contrytoggle = get_field( "country_toggle" ); $contrypri = get_field( "select_country" ); ?> <?php echo $contrytoggle; ?> <?php $custom_ids = my_custom_ids($contrytoggle, $contrypri); $has_members_args = array( 'include' => $custom_ids, ); echo $custom_ids; // This shows correct number of ids if ( bp_has_members() ) : ?> <ul> <?php while ( bp_members() ) : bp_the_member(); ?> <li> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a> </div> <div class="item"> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a> </div> </li> <?php endwhile; ?> </ul> <?php else: ?> <div id="message" class="info"> <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p> </div> <?php endif; ?> </div>
Hi Shane,
Even if I check condition it still shows all members.
<?php <?php if ( !empty(bp_has_members( my_custom_ids( 'country', 'usa' ) ) ) ) : ?> <ul> <?php while ( bp_members() ) : bp_the_member(); ?> <li> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a> </div> <div class="item"> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a> </div> </li> <?php endwhile; ?> </ul> <?php else: ?> <div id="message" class="info"> <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p> </div> <?php endif; ?> </div>
I use the function “my_custom_ids” Loop
Thanks @shanebp for response. OK I played around and here is my code. Its working fine but with one issue i.e
If there is no value it echo’s all the members.
<?php $contrytoggle = get_field( "country_toggle" ); $contrypri = get_field( "select_country" ); ?> <?php echo $contrytoggle; ?> <?php if ( bp_has_members( my_custom_ids( $contrytoggle, $contrypri ) ) ) : ?> <ul> <?php while ( bp_members() ) : bp_the_member(); ?> <li> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a> </div> <div class="item"> <div class="item-title"> <a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a> </div> </li> <?php endwhile; ?> </ul> <?php else: ?> <div id="message" class="info"> <p><?php _e( "Sorry, no members were found.", 'buddypress' ); ?></p> </div> <?php endif; ?>
NO one ?