Score:0

Get Group Name (label) of group the currently logged in user is in

cn flag

We have created several groups using the groups module in Drupal 9. We have assigned some users to these groups. A user can only be in one group. Now when the user is logged in, we have block in the header that displays some user info. One of the things we want to display is the name of the group the user belongs to. I have a hook_preprocess_block in my .theme file already where I am loading the current user, but I'm not sure how to get the name of the group they are in. I can get the name of the group just fine if they are already on a group page by using $group = \Drupal::routeMatch()->getParameter('group'); , but we may have pages they go to including even the user profile page which is not a group page, so we really want to be able to get the group from the user itself instead of the group page they are on.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.