admin管理员组文章数量:1134247
I am new in buddypress.
My problem is: I have create a template for get member list based on role Like:
<?php if ( bp_has_members( bp_ajax_querystring( 'members' ). '&per_page=25&role=author' ) ) : ?>
<ul id="members-list" class="item-list row kleo-isotope masonry">
<?php while ( bp_members() ) : bp_the_member(); ?>
<li><a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a></li>
<?php endwhile; ?>
</ul>
But i am not getting user list based on role. Please help me and suggest me any idea.
I am new in buddypress.
My problem is: I have create a template for get member list based on role Like:
<?php if ( bp_has_members( bp_ajax_querystring( 'members' ). '&per_page=25&role=author' ) ) : ?>
<ul id="members-list" class="item-list row kleo-isotope masonry">
<?php while ( bp_members() ) : bp_the_member(); ?>
<li><a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a></li>
<?php endwhile; ?>
</ul>
But i am not getting user list based on role. Please help me and suggest me any idea.
Share Improve this question edited Aug 8, 2015 at 1:09 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Aug 7, 2015 at 6:24 AddyAddy 1761 silver badge9 bronze badges2 Answers
Reset to default 3To preserve pagination, try:
<?php
$authors = get_users( array( 'fields' => 'ID', 'role' => 'author' ) );
$authors = implode(',', $authors);
?>
<?php if ( bp_has_members( bp_ajax_querystring( 'members' ). '&per_page=25&include=' . $authors) ) : ?>
//etc
If you use this code directly below while ( bp_members() ) : bp_the_member();
in the members loop, you’ll be able to see which members are author.
<?php
$user_id = bp_get_member_user_id();
$user = new WP_User( $user_id );
if ( $user->roles[0] == 'author' ) {
echo 'this user is an author';
}
?>
I know this isn’t exactly what you’d like to do but it should put you on the right track.
Note: This code assumes that all of your users have a single role assigned.
本文标签: pluginsHow to get member list based on role by using buddypress
版权声明:本文标题:plugins - How to get member list based on role by using buddypress? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736825294a1954462.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论