The [groups_user_groups] shortcode allows us to show the groups that are related to a user.

It lists the groups that the current user or a specific user (identified by user ID, login or email) belongs to.

The following optional attributes can be used:

  • user_id : If a user ID is given, it displays the groups for that user (*).
  • user_login : If the username (aka login) is provided, the shortcode displays groups for that user (*).
  • user_email : Identifies the user whose groups should be displayed by the email address related to the user account (*).
  • group : One or more group names or IDs, separated by comma.
    This limits the groups displayed to those indicated.
  • exclude_group : One or more group names or IDs, separated by comma.
    This excludes the indicated groups from display.
  • format : The format of the HTML output of the list of groups.
    Available options are: "list""div""ul" or "ol", where "list" and "ul" are equivalent.
    The default is "list".
  • list_class : CSS class applied to the list.
  • item_class : CSS class applied to each list item.
  • order_by : The list of groups is ordered by "name" (default) or by "group_id".
  • order : Used to indicate whether the groups should be listed in ascending or descending order.
    Allowed values are "asc" and "desc".
    The default is "asc" for ascending order.

(*) If none of the user_id, the user_login or the user_email are provided, the shortcode shows the groups of the current user.