Skip to:
Content
Pages
Categories
Search
Top
Bottom

list members Order by custom field


  • w-prog
    Participant

    @w-prog

    Hi,
    I created a new custom field in Buddy Press : classement
    I would order my list member on this custom field
    I understood that I can add a new order type with :

    function custom_add_members_directory_order_options() {
    	?>
    	<option value="rang"><?php _e( 'Par rang', 'willy-bp-custom' ); ?></option>
    	<?php
    }
    add_action( 'bp_members_directory_order_options', 'custom_add_members_directory_order_options' );
    

    And ordering with this :

    
    add_action( 'bp_pre_user_query', 'custom_pre_user_query', 10, 1 );
    function custom_pre_user_query( $user_query = null ) {
    	global $wpdb;
    $user_query->uid_clauses['orderby'] = 'ORDER BY classement'; // Here is my new fields
    	$user_query->uid_clauses['order']   = 'DESC';
    }
    

    But I’m not sur hat the order instruction is correct because the fields’ name isn’t classement is database (cf tables bp_xprofile_date and bp_xprofile_field)
    Have you a solution for that please?
    Best regards

  • You must be logged in to reply to this topic.
Skip to toolbar