Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Andrea Tarantini

    (@dontdream)

    Hello damland,

    Please comment out the line:

    $BP_User_Query->uid_clauses['select'] = ...

    Does that help?

    Thread Starter DAM

    (@damland)

    @dontdream No, without that line it doesn’t work

    You can use this for tests, it search for a value inside user_meta

    
    function users_sortby_points( $object ) {
        global $wpdb;
    
    	// Adjust SELECT
    	$object->uid_clauses['select'] = "
    	SELECT $wpdb->usermeta.user_id AS id
    	FROM $wpdb->usermeta";
    
    	// Adjust WHERE
    	$object->uid_clauses['where'] = "WHERE $wpdb->usermeta.meta_key = 'userpoints'";
    
    	// Adjust ORDER BY
    	$object->uid_clauses['orderby'] = " ORDER BY $wpdb->usermeta.meta_value";
    
    	// Adjust ORDER
    	$object->uid_clauses['order'] = 'DESC';
    }
    add_action( 'bp_pre_user_query', 'users_sortby_points' );
    
    function add_sortby_point() {
    echo '<option value="points">Points</option>';
    }
    add_action( 'bp_members_directory_order_options', 'add_sortby_point', 1, 0 );
    
    • This reply was modified 5 years, 6 months ago by DAM.
    • This reply was modified 5 years, 6 months ago by DAM.
    Plugin Author Andrea Tarantini

    (@dontdream)

    Hi damland,

    I should reproduce your environment on my test site to debug this problem, but trying to reproduce someone else’s installation takes a lot of work, and I’m unable to do it.

    I am willing to take a look at people’s actual installations, but this is against the policy of this forum. If you are interested, you can use my Contact page to continue this conversation.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Orderby sorting’ is closed to new replies.