-
Author
Tagged: exclude, roles, top members
-
May 24, 2014 at 22:06 #18770AdamParticipant
We’re going to show 4 active or popular members on the home page and I’m using the code below, but I need to limit the results to ONLY displaying users with a role of ‘subscriber’, as we have many editors, administrators and contributors who should not be included here ever.
COPY CODEfunction kleo_top_members( $atts, $content = null ) { extract(shortcode_atts(array( 'style' => 'standard' ), $atts)); $output = ' <div class="section-members"> <div class="item-options" id="members-list-options"> <a href="'.bp_get_members_directory_permalink().'" data-id="newest" class="members-switch">'.__("Newest", 'kleo_framework').'</a> <a href="'. bp_get_members_directory_permalink().'" data-id="active" class="selected members-switch">'.__("Active", 'kleo_framework').'</a> <a href="'.bp_get_members_directory_permalink().'" data-id="popular" class="members-switch">'.__("Popular", 'kleo_framework').'</a> </div>'; $output .= '<ul class="item-list kleo-bp-active-members" style="display:none;">'; if ( bp_has_members( 'type=active&max=4' ) ) : while ( bp_members() ) : bp_the_member(); $output .= mm_section_members_li(); endwhile; endif; $output .='</ul>'; $output .= '<ul class="item-list kleo-bp-newest-members" style="display:none;">'; if ( bp_has_members( 'type=newest&max=4' ) ) : while ( bp_members() ) : bp_the_member(); $output .= mm_section_members_li(); endwhile; endif; $output .='</ul>'; $output .= '<ul class="item-list kleo-bp-popular-members" style="">'; if ( bp_has_members( 'type=popular&max=4' ) ) : while ( bp_members() ) : bp_the_member(); $output .= mm_section_members_li(); endwhile; endif; $output .='</ul>'; $output .= '</div><!--end section-members-->'; $output .= <<<JS <script type="text/javascript"> jQuery(document).ready(function() { jQuery(".members-switch").click(function() { var bpMembersContext = jQuery(this).parent().parent(); var container = "ul.kleo-bp-"+jQuery(this).attr('data-id')+"-members"; jQuery("ul.item-list", bpMembersContext).hide(); jQuery(".members-switch").removeClass("selected"); jQuery(this).addClass("selected"); jQuery(container, bpMembersContext).show(0, function() { jQuery(container+" li").hide().each(function (i) { var delayInterval = 150; // milliseconds jQuery(this).delay(i * delayInterval).fadeIn(); }); }); return false; }); }); jQuery(function () { jQuery('.kleo-bp-active-members').hide(); jQuery('.section-members').one('inview', function (event, visible) { if (visible) { var container = ".kleo-bp-active-members"; jQuery(container).show(0, function() { jQuery(container+" li").hide().each(function (i) { var delayInterval = 150; // milliseconds jQuery(this).delay(i * delayInterval).fadeIn(); }); }); } }); }); </script> JS; return $output; } add_shortcode('kleo_top_members', 'kleo_top_members');
May 24, 2014 at 22:48 #18772AdamParticipantI should say – I’m using BP 2.0 so is it easier to a custom bp loop other than the Top Members bp_parse_args instead of kleo_top_members?
May 24, 2014 at 23:02 #18773AdamParticipantso right now I’m just adding all of the admins/editors/contributors user ids to an &exclude= .. but this doesn’t seem ideal. So any shortcuts to a by-role solution would be appreciated!
May 29, 2014 at 01:01 #19024AbeKeymasterHi, see this gist and it could be a starting point for you https://gist.github.com/dzmounir/8285459
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer. -
AuthorPosts
You must be logged in to reply to this topic.