Groups’ shortcodes are used to protect content sections, show group information, let a user join or leave a group, show user or site groups etc.

Don’t worry if you are not familiar with the usage of shortcodes, easy to follow examples are provided in each section to show you how to use them. Using shortcodes is not coding – to give you an idea of how super easy to use this is, the example below shows how you can restrict content to be displayed for registered users only – you can use snippets like this anywhere on a post, a page and other types of entries on your site:

[groups_member group="Registered"]
Only registered members can see this.

As in this example, many shortcodes require you to indicate an attribute. This is so that Groups knows how to act, based on hints about groups, capabilities or other information it requires along with the shortcode. Note that you pass information to these attributes enclosed within plain double quotes ".

The following sections provide details on the usage of the shortcodes included in Groups:

We provide usage examples where appropriate in each of these sections.

Shortcode … what?

If this all sounds very strange to you and you never heard of or used shortcodes, then it’s recommended to make yourself familiar with them. You can read more about WordPress’ shortcodes in general on the Shortcode codex page.

Visual Appearance

Please note that how the shortcodes are rendered depends on the theme that is being used. Groups is pretty neutral and lets you customize the output using simple CSS rules.

Depending on your theme, don’t expect the output you obtain to look exactly as in our examples.

The HTML that our shortcodes produce can be themed easily, as it usually adds appropriate CSS classes to key elements rendered.

Using shortcodes in Templates

Besides placing shortcodes on posts, pages, etc., you can use the shortcodes in your PHP template files. We can use WordPress’ do_shortcode() function for this purpose.

Here is a very simple example that will render the text Hello member! for registered users:

echo do_shortcode( '[groups_member group="Registered"]Hello member![/groups_member]' );

Here is a more complex example that shows some text and the login form for those who are not logged in:

<h1><?php _e( 'Welcome', 'example' ); ?></h1>
$login_content = sprintf(
'[groups_non_member group="Registered"]<p>%s</p>[groups_login][/groups_non_member]',
__( 'Please log in:', 'example' )
echo do_shortcode( $login_content );