Skip to:
Content
Pages
Categories
Search
Top
Bottom

Sorting members by id in members-loop


  • webmister76
    Participant

    @webmister76

    I would like to display the members order by user_id.
    I mean that in the list, old members have to be on the top, and new members have to follow.

    Is there anything that I can add in members-loop.php?

    I’m looking for it since this morning :S

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

  • danbp
    Moderator

    @danbp


    webmister76
    Participant

    @webmister76

    Wow… I didn’t see “type=newest” before now :S
    Thank you for help 🙂

    Now I only miss to display oldest first, and then newest.
    It looks like “order” is not an accepted parameter…


    webmister76
    Participant

    @webmister76

    bp-core-classes.php

    277 
    				if ( 'newest' == $type ) {
    					$sql['orderby'] = "ORDER BY u.user_id";
    					$sql['order'] = "DESC";
    
    
    				if ( 'newest' == $type ) {
    					$sql['orderby'] = "ORDER BY u.user_id";
    					$sql['order'] = "ASC";

    danbp
    Moderator

    @danbp

    Don’t hack core files !

    It will be overwriten at next BP update.

    Use preferably a filter function. Give this a try (add it to bp-custom.php) :

    function members_dir_oldest_first( $bp_user_query ) {
        if ( 'newest' == $bp_user_query->query_vars['type'] )       
    		$bp_user_query->uid_clauses['order'] = "ASC";
    }
    add_action ( 'bp_pre_user_query', 'members_dir_oldest_first' );
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sorting members by id in members-loop’ is closed to new replies.
Skip to toolbar