The discussion revolves around accessing a user’s groups in a Discourse plugin without making a request. kleinfreund initially tries to access Discourse.User.current().groups but finds it’s not exposed on all pages. vinothkannans suggests adding custom plugin code to the serializer to achieve this, which kleinfreund successfully implements.
Later, Falco and zogstrip discuss adding this functionality by default for the current user serializer, which maja confirms has been implemented in a recent commit.
Additionally, kleinfreund asks how to access a user’s groups in the Rails application, and david responds that current_user.groups should work, which kleinfreund confirms after retrying.
However, I would prefer to not send a request for this information if I can get it without. Is there a way to list a user’s groups without sending a request?
I need to access a user’s group within my plugins Ember route.
You can add custom plugin code to achieve this. Something similar to below code (unverified). Then you can access it like Discourse.User.current().groups
How does one get a user’s groups in the Rails application? Via current_user, I have access to a user’s username, etc. but I can’t find a way to access their groups.