Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Sort by Role

  • @creativeslice

    Participant

    Is there a way to show a member list by role? So members who have the role “editor” would show up in a member list? This would probably be a modification of:

    if ( bp_has_members( ‘type=active&max=20& —> USER TYPE = EDITOR <— ' ) ) :

    Thanks in advance for any help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • @lancewillett

    Participant

    Why not just use a group for this?

    There isn’t a way to do this in BuddyPress without writing your own code to do it. You could use WP_User_Search to look up users, it is defined in /wp-admin/includes/user.php starting near line 637.

    Here’s an example from http://www.clarksonenergyhomes.com/wordpress/2009/03/16/wp-get-users-by-role-function/ (found via Google).


    function get_users_with_role ( $role ) {
    // gets all users with specified role
    $wp_user_search = new WP_User_Search( '', '', $role );
    return $wp_user_search->get_results();
    }

    This type of user search is intended for use in Administration Panels, not on public-facing pages. So be sure you know why you’re exposing that information before you do it. I’d urge against ever showing a member’s user role publicly. It’d probably be much better to use a Group for those users and display them that way — based on their membership in a certain group instead of their user role.

    @creativeslice

    Participant

    Thanks for the tip Lance. I ended up doing it this way with “s2member_level4” as the custom role:

    http://bpdev.pastebin.com/0whWjpvx

    @tammyhart

    Participant

    AWEsome! thank you so much for that code!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Sort by Role’ is closed to new replies.
Skip to toolbar