Hi,
thank you for reaching out and your kind words. I will try to help you but our lead developer Chris is not available at the moment so I am sure there is a better solution then what I can come up with and maybe this thread gets an update when he is back :).
I was not able to find a fitting hook or function that does what you need, but if you are comfortable querying the database directly you could try something like this:
function get_grouplist_by_user_id($userId){
global $wpdb;
$userToGroups = $wpdb->prefix . CLUEVO_DB_TABLE_USERS_TO_GROUPS;
$wpUser = $wpdb->prefix . 'users';
$query = $wpdb->prepare(
"SELECT ug.group_id FROM $userToGroups ug JOIN $wpUser u ON ug.user_id = u.ID WHERE ug.user_id = %s",
$userId
);
$groupList = $wpdb->get_results($query);
return $groupList;
}
notice: a user can be in multiple groups
I hope this helps and all the best,
Elias
This is incredibly useful – thank you Elias!