Support Forum

Are you referring to the standard members list as generated when you click on the 'members' button in the forum header?
I am assuming so and if this is the case then that list should be ordered (by default) by the user ID. Can you double check the assertion regarding first name?
![]() |
YELLOW
SWORDFISH
|

OK - third post before you have had a chance to respond! Bit I have been researching.
Using either the first_name or the last_name data items is actually really rather difficult, cumbersome and a bit of a performance drag. This is because of the really rather nasty way that WordPress chooses to store this data. It can be done but there IS a penalty for doing so. This is why we default to display_name.
So - it can be done using a standard WP filter but it is not recommended. Up to you of course...
![]() |
YELLOW
SWORDFISH
|

Well I am researching and trying but at the moment I am not now even sure it is possible. It really is a hideous way to store data... If I can come up with a solution I will post back here...
And if any SQL guru is reading this and knows if it is possible to JOIN the usermeta table on only the row with a meta_key of 'last_name' then perhaps they can let me know the secret!
![]() |
YELLOW
SWORDFISH
|

OK - this might have got it actually. Give it a try..
Add the following to your spFunctions.php file which is in the /templates folder of your Simple:Press theme. You can use the SP theme editor for this of course. It MUST be EXACT so use the raw copy button to copy it...
add_filter('sph_members_list_query', 'my_members_sort'); function my_members_sort($q) { $q->fields .= ', meta_value AS last_name '; $q->left_join .= " LEFT JOIN ".SFUSERMETA." ON (".SFUSERMETA.".user_id=".SFMEMBERS.".user_id AND ".SFUSERMETA.".meta_key='last_name')"; $q->orderby = "usergroup_id ASC, last_name ASC"; return $q; }
See if that does what you want.
Three important things to remember if it DOES work for you.
- Expect it to take a little longer to compile and execute
- If any of your members have NOT recorded their last_name then they will appear at the top of their user group list because their data will be a null.
- You will need to make a child theme or custom theme to avoid this function being lost on future SP updates.
Let me know if it works.
![]() |
YELLOW
SWORDFISH
|
1 Guest(s)