Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to display all members in order to asc/desc by user id


  • xidea
    Participant

    @xidea

    Hi~ everyone~
    I’m a new BuddyPress user and I want to display all members from old to new in the MEMBERS-LOOP.But it seems no optional like “ORDER” in the bp_has_members() function and others.

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

  • aljo1985
    Participant

    @aljo1985

    Just do a select query to the wordpress database. and echo the results.

    // Query
    global $wpdb;
    $rows = $wpdb->get_results("
    	SELECT id, display_name
    	FROM " . $wpdb->prefix . "users
    	ORDER BY id DESC LIMIT 20"
    );
    // Show 'em...
    foreach($rows as $row):
    	echo $row->display_name;
    endforeach;

    Just change limit, to how many you want to display and DESC to ASC for order.

    Enjoy, my last post!


    shanebp
    Moderator

    @shanebp

    @aljo1985
    WP provides a function for getting users. No need for custom sql.
    https://codex.wordpress.org/Function_Reference/get_users


    @xidea

    Have you tried
    bp_has_members( bp_ajax_querystring( 'members' ) . '&type=newest' )

    Members Loop


    aljo1985
    Participant

    @aljo1985

    Thanks for the info, I am actually new to WordPress and have not looked through all the functions. I have only built custom queries on custom tables on my own website that I am currently developing.
    I have tried wordpress in the past but then switched to other platforms as they was more adequate for my goals.

    But right now I am sticking with wordpress and building a new website :),
    I’m more use to sources and templates, scripting from scratch.

    Out of curiosity, which one is better on performance? A straight up query OR the function above.
    If there is security concerns with using a query, apart from sanitisation which I know and use on every custom table, then that info would be good to know also.

    Thanks.

    Edit, I would like to report a bug in your software, even though you posted this reply I got a notification for a reply in the first topic I made. I had no idea you replied to this other than looking through the latest list of topics.

    Here is a screen shot
    target=”_blank”>https://i.imgur.com/wxSgfsG.png

    Here is the topic in question that I got the notification for which only has 1 reply, but was from other topics.
    https://buddypress.org/support/topic/how-do-i-remove-textarea-resize-without-editing-the-js-script/?action=bbp_mark_read&topic_id=236164&_wpnonce=d849ee20f9#post-236164


    xidea
    Participant

    @xidea

    thx a lot.
    Let me try~

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to display all members in order to asc/desc by user id’ is closed to new replies.
Skip to toolbar