Shortcodes

There are several shortcodes that you can use in your post editor or any shortcode-ready area..

[members_access]

The [members_access] shortcode is for hiding content from particular roles and capabilities. You need to wrap your content when using this shortcode:

[members_access role="editor"]Hide this content from everyone but editors.[/members_access]

The plugin accepts the following parameters (mixing and matching won’t work):

  • role – A single or comma-separated list of roles.
  • capability – A single or comma-separated list of capabilities.
  • user_name – A single or comma-separated list of usernames.
  • user_id – A single or comma-separated list of user IDs.
  • user_email – A single or comma-separated list of user email addresses.

Parameters:

  • capability: A capability that has been assigned to a role.
  • role: A user role from WordPress or one that you’ve created.
  • operator: Accepts ! to negate the role or capability.

Note that capability and role parameters aren’t used in conjunction. The code first checks for the capability (if input) then checks for the role (if input).

To check for multiple capabilities or multiple roles, simply add a comma between each capability/role. For example, the following code checks for an editor or administrator:

[members_access role="administrator,editor"]Show this content to administrators or editors only.[/members_access] 

To check that the user does not have a role:

[members_access role="administrator" operator="!"]Show this content to anyone who is not an administrator.[/members_access]

[members_logged_in]

The [members_logged_in] shortcode should be used to check if a user is currently logged into the site. If not, the content will be hidden.

[members_logged_in]This content is only shown to logged-in users.[/members_logged_in]

This shortcode has no parameters.

[members_not_logged_in]

The [members_not_logged_in] shortcode should be used to show content to users who are not logged into the site. If the user is logged in, the content will be hidden.

[members_not_logged_in]This content is only shown to logged-out visitors.[/members_not_logged_in]

[members_login_form]

The [members_login_form] shortcode is used to show a login form on the page.

[members_login_form /] 

This shortcode has no parameters.

The Members plugin uses default login WordPress functionality so we don’t have redirection functionality. To redirect users, you can try to use Peter’s Login Redirect plugin that redirects users to a custom URL after login. You can also adjust it for each role separately.