Primary

[groups_join]

This shortcode provides an easy way for users to join a specific group. You simply provide the name of the group and it renders a button that your users can click to join the group. For example, this lets users join a Test group, provided that the group exists:

[groups_join group="Test"]

The shortcode takes the following attributes to let a user join a specific group:

  • group : (required) The group ID or name.
  • class : (optional) Additional CSS class(es) to apply to the container that holds the HTML elements rendered. The container has the class groups-join by default.
  • display_message : (optional) Whether to show a confirmation after joining the group. 
Accepted values are: true and false. 
Defaults to true.
  • display_is_member : (optional) Whether to show that the user is a member of the group.
 Accepted values are: true and false.
 Defaults to false.
  • submit_text : (optional) Specify this to change the button text template.
 To show the name of the group, it must contain the placeholder %s where the group name should appear. 
The default button text template is "Join the %s group".
  • submit_class : (optional) Additional CSS class(es) to apply to the submit HTML input element. The element has the class groups-join-submit by default. For example, adding wp-element-button would style this like other buttons (depending on your theme).

With the latest version of Groups, the shortcode will render if the author of the page has the permission to Restrict Access. This permission can be granted to certain roles or by assigning the groups_restrict_access capability to a group to allow its members to use it. Only users you trust to allow others to join as group members should be granted this permission.

Example

Let’s assume that you want to show specific information to users in the Test group created for that purpose. You could let users join this group when interested by placing this shortcode on a post or page:

Click the button to become a member: [groups_join group="Test"]

The shortcode could render like this for users who do not yet belong to the group:

As you can see, a simple button lets users join the group easily.

If we provide additional CSS classes like wp-element-button, the appearance can be adjusted to match that of the theme if it supports it.

Click the button to become a member: [groups_join group="Test" submit_class="wp-element-button"]

With the Twenty Twenty-Five theme, it renders like this: