fetching specfic role users
-
hi
i’m trying to fetch specific users of role “expert” with this code, but its giving some random 3 users.
<?php if ( bp_has_members( bp_ajax_querystring( 'expert' ) ) ) : while ( bp_members() ) : bp_the_member(); ?>
also, how do i increase the users from 3 to all available in that specific role. I am building a slider.
http://31.216.48.18/~farmcom/
-
Try:
<?php $experts = get_users( 'fields=ID&role=expert' ); $args = array( 'include' => $experts, 'per_page' => 500 // the number of members that you have ); if ( bp_has_members( bp_ajax_querystring( 'members' ) . $args ) ) : while ( bp_members() ) : bp_the_member(); ?>
@shanebp , thanks .. just tried, and gives the same result.
Then some code from some other plugin or theme is interfering.
To find out, try turning off other plugins and switching to a WP theme like 2015.tried switching everything, didn’t work
Try it with subscribers.
get_users( 'fields=ID&role=subscriber' );
If that works, then it’s a clue that there is an issue re your ‘expert’ role.
replaced the code, and its same
Try:
if ( bp_has_members( bp_ajax_querystring( 'members' ) . '&per_page=500&include=' . $experts ) ) :
i inserted this code, and nothing showsup on the frontend expert block
<?php $experts = get_users( 'fields=ID&role=expert' ); $args = array( 'include' => $experts, 'per_page' => 500 // the number of members that you have ); if ( bp_has_members( bp_ajax_querystring( 'members' ) . '&per_page=500&include=' . $experts ) ) : while ( bp_members() ) : bp_the_member(); ?>
any solution?
- You must be logged in to reply to this topic.