WordPress.org

Support

Support » Plugins and Hacks » Simple User Listing » [Resolved] orderby="user_lastname" ?

[Resolved] orderby="user_lastname" ?

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

    @helgatheviking

    user_lastname is not one of the orderby values supported by WP_User_Query.

    I can’t push it live now, but by the weekend (as of version 1.5.2) you will be able to sort by last name via the following:

    [userlist meta_key="last_name" orderby="meta_value" order="ASC"]

    In the mean time (the time it takes for me to traverse the Atlantic ocean) you can filter the query via pre_user_query which is your chance to modify the user query, much like pre_get_posts does for post queries.

    function kia_sort_by_last_name( $query ){
    	if(  isset( $query->query_id ) && $query->query_id == 'simple_user_query' ){
    		$query->set( 'meta_key', 'last_name' );
    		$query->set( 'orderby', 'meta_value' );
    		$query->set( 'order', 'ASC' );
    	}
    }
    add_filter( 'pre_user_query', 'kia_sort_by_last_name' );

    Many thanks!!

    Plugin Author helgatheviking

    @helgatheviking

    Update is just being pushed out now.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] orderby="user_lastname" ?’ is closed to new replies.
Skip to toolbar