Skip to:
Content
Pages
Categories
Search
Top
Bottom

fetching specfic role users


  • Ashim Adhikari
    Participant

    @masterashim

    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/

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

  • shanebp
    Moderator

    @shanebp

    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();
    ?>

    Ashim Adhikari
    Participant

    @masterashim

    @shanebp , thanks .. just tried, and gives the same result.


    shanebp
    Moderator

    @shanebp

    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.


    Ashim Adhikari
    Participant

    @masterashim

    tried switching everything, didn’t work

    http://31.216.48.18/~farmcom/


    shanebp
    Moderator

    @shanebp

    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.


    Ashim Adhikari
    Participant

    @masterashim

    replaced the code, and its same


    shanebp
    Moderator

    @shanebp

    Try:

    if ( bp_has_members( bp_ajax_querystring( 'members' ) . '&per_page=500&include=' . $experts ) ) :


    Ashim Adhikari
    Participant

    @masterashim

    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();
    ?>

    Ashim Adhikari
    Participant

    @masterashim

    @shanebp

    any solution?

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar