On the subaccounts page (/my-account/subaccounts/), names are currently displayed as First Name Last Name and the list is not sorted in a controllable way.
Can you help us with showing the last name first and then first name. And if we can sort the subaccounts by A - Z of their name in my account / subaccounts page.
I've made a change to the plugin to allow doing this with a code snippet. Please update to the attached plugin version. Alternatively, you can also just wait a few days for the official release, we are expecting a plugin update by this weekend.
To update:
1. First deactivate your existing version of B2BKing Pro
2. Upload and activate the attached version
After updating, add the following PHP code snippet to the site:
// 1. Show last name before first name
add_filter('b2bking_subaccount_display_name', function($display_name, $first, $last, $subaccount_id){
return trim($last.' '.$first);
}, 10, 4);
// 2. Sort subaccounts A–Z by last name, then first name
add_filter('b2bking_subaccounts_before_display', function($subaccount_ids){
usort($subaccount_ids, function($a, $b){
$a_key = get_user_meta($a, 'last_name', true).' '.get_user_meta($a, 'first_name', true);
$b_key = get_user_meta($b, 'last_name', true).' '.get_user_meta($b, 'first_name', true);
return strcasecmp(trim($a_key), trim($b_key));
});
return $subaccount_ids;
});
This can be added to functions.php, or to any code snippets plugin,
Hi,
On the subaccounts page (/my-account/subaccounts/), names are currently displayed as First Name Last Name and the list is not sorted in a controllable way.
Can you help us with showing the last name first and then first name. And if we can sort the subaccounts by A - Z of their name in my account / subaccounts page.
Thank you so much for your support!
Hi there,
I've made a change to the plugin to allow doing this with a code snippet. Please update to the attached plugin version. Alternatively, you can also just wait a few days for the official release, we are expecting a plugin update by this weekend.
To update:
1. First deactivate your existing version of B2BKing Pro
2. Upload and activate the attached version
After updating, add the following PHP code snippet to the site:
// 1. Show last name before first name add_filter('b2bking_subaccount_display_name', function($display_name, $first, $last, $subaccount_id){ return trim($last.' '.$first); }, 10, 4); // 2. Sort subaccounts A–Z by last name, then first name add_filter('b2bking_subaccounts_before_display', function($subaccount_ids){ usort($subaccount_ids, function($a, $b){ $a_key = get_user_meta($a, 'last_name', true).' '.get_user_meta($a, 'first_name', true); $b_key = get_user_meta($b, 'last_name', true).' '.get_user_meta($b, 'first_name', true); return strcasecmp(trim($a_key), trim($b_key)); }); return $subaccount_ids; });This can be added to functions.php, or to any code snippets plugin,
Let me know if you run into any issues with it,
Kind regards,
Stefan