I want to set up a View that outputs users and I want to have them sorted alphabetically by the last name of the user. The solution provided in this older ticket leads to a dead page. Can you assist with providing whatever code snippet is needed to accomplish this? Last Name is not one of the options provided for sorting in the User View.
As you may notice there is no option available to sort the user query by last_name.
As a workaround:
- edit your view and navigate to "Query Filter" section:
- Add a query filter for the last name field where last_name is a string different from emppy value
Then navigate to: Toolset => Settings => Custom Code tab and add a code snippet and add the following code to the code snippet you create and activate the code snippet.
To order by user's last_name, please try to use the hook "wpv_filter_user_query":