Groups

Posted by kento on January 12, 2012 9:22 pm
Groups is a WordPress plugin that provides group-based user membership management, group-based capabilities and content access control. It integrates standard WordPress capabilities and application-specific capabilities along with an extensive API.

Features

User groups

  • Supports an unlimited number of groups
  • Provides a Registered group which is automatically maintained
  • Users can be assigned to any group
  • Users are added automatically to the Registered group

Groups hierarchy

  • Supports group hierarchies with capability inheritance

Group capabilities

  • Integrates standard WordPress capabilities which can be assigned to groups and users
  • Supports custom capabilities: allows to define new capabilities for usage in plugins and web applications
  • Users inherit capabilities of the groups they belong to
  • Groups inherit capabilities of their parent groups

Access control

  • Built-in access control that allows to restrict access to posts, pages and custom content types to specific groups and users only
  • control access to content by groups: shortcodes allow to control who can access content on posts, show parts to members of certain groups or to those who are not members Shortcodes: [groups_member], [groups_non_member]
  • control access to content by capabilities: show (or do not show) content to users who have certain capabilities Shortcodes: [groups_can], [groups_can_not]

Easy user interface

  • integrates nicely with the standard WordPress Users menu
  • provides an intuitive Groups menu
  • conceptually clean views showing the essentials
  • quick filters
  • bulk-actions where needed, for example apply capabilities to groups, bulk-add users to groups, bulk-remove users from groups

Sensible options

  • administrator overrides can be turned off
  • optional tree view for groups can be shown only when needed
  • provides its own set of permissions
  • cleans up after testing with a “delete all plugin data” option

Access Control

Groups defines some capabilities of its own. The groups_read_post capability is used to restrict access to certain posts or pages to groups (and users) with that capability only.

Framework

  • Solid and sound data-model with a complete API that allows developers to create group-oriented web applications and plugins

Multisite

  • All features are supported independently for each blog in multisite installations

Your opinion counts

You & Groups

Beta-testers and developers who need to integrate group-based features in their plugins and web applications: please use it and provide your feedback.

Feedback

Feedback is welcome!

If you need help, have problems, want to leave feedback or want to provide constructive criticism, please do so here at the Groups plugin page.

Please try to solve problems there before you rate this plugin or say it doesn’t work. There goes a lot of work into providing you with free quality plugins! Please appreciate that and help with your feedback. Thanks!

Twitter

Follow me on Twitter for updates on this and other plugins.

Introduction

Content Access Control

Access restrictions on posts

On posts an pages (and custom content types) a new meta box titles Access restrictions appears. By checking Enforce read access, you can restrict access to the post to groups and users who have the groups_read_post capability. You need to assign this capability to a group and make users members of that group to allow them to see those posts.

Content visibility for members and non-members

The [groups_member] and [groups_non_member] shortcodes are used to limit visibility of content to users who are members of a group or users who are not members of a group. Multiple comma-separated groups can be specified.

Example: Limiting visibility of enclosed content to registered users.

[groups_member group="Registered"]

Only registered users can see this text.

[/groups_member]

Content visibility based on capabilities

The [groups_can] and [groups_can_not] shortcodes limit visibility of enclosed content to those users who have the capability or those who do not have it. Multiple capabilities can be given.

Example: Showing enclosed content to users who can edit_posts (standard WordPress capability).

[groups_can capability="edit_posts"]

You can see this only if you have the edit_posts capability.

[/groups_can]

Integration in the ‘Users’ menu:

Users – group membership is managed from the standard Users admin view. Users are automatically added to the Registered group. You can add multiple users to other groups here and also remove them.

Sections in the ‘Groups’ menu:

Groups

Here you can:

  • add groups
  • remove groups
  • assign capabilities to groups

Capabilities

This is where you add, remove and manage capabilities.

Capabilities can be assigned to groups and users (1). These capabilities include the standard WordPress capabilities but you can also define additional capabilities for your web-application.

Groups defines some capabilities of its own. The groups_read_post capability is used to restrict access to certain posts or pages to groups (and users) with that capability only.

(1) Assigning capabilities to users is not integrated in the user interface yet but can be done through API calls.

Options

Administrator override :

Administrator overrides can be turned off.

Permissions :

For each role these permissions can be set:

  • Access Groups: see information related to Groups.
  • Administer Groups: complete control over everything related to Groups.
  • Administer Groups plugin options: grants access to make changes on the Groups > Options admin section.

Testing the plugin :

A convenient option is provided to delete all data that has been stored by the Groups plugin. This option is useful if you just need to start from fresh after you have been testing the plugin.

Shortcodes

Limit content visibility

These shortcodes are used to limit the visibility of the content they enclose:

  • [groups_member]
  • [groups_non_member]
  • [groups_can]
  • [groups_can_not]

See above for examples and descriptions.

Show group information

  • [groups_group_info]

This shortcode takes the following attributes to show information about a group:

  • group : (required) the group ID or name
  • show : (required) what to show, accepted values are: name, description, count
  • single : (optional) used when show=”count” and there is 1 member in the group
  • plural : (optional) used when show=”count” and there is more than 1 member in the group, must contain %d to show the number of members

Examples:

  • [groups_group_info group="Registered" show="count"]
  • There [groups_group_info group="1" show="count" single="is one member" plural="are %d members"] in the [groups_group_info group="1" show="name"] group.

Download

Download the Groups plugin on WordPress.

About kento
Computer Science Engineer, IT & Business Consultant, Drupal, WordPress, Scenario Planning ...

27 comments

  • Claudio

    hi..looks good …ithere any way or shortcode i can use to show the number of registered users in a group or sub group.
    ciao
    Claudio

  • shawn

    Is there currently any way to say ‘if user-group = x’ then ‘allow access to blog id#4′ in a WordPress multisite subfolder installation?

    Basically I created a blog ‘members’ in multisite where all of my members content resides. Trying to find the easiest solution to only allow certain groups to access that blog. guests/visitors see page saying members-only with options to register.

    Is this currently, or considered for future updates?

    *After a lot of trying determined s2members is not capable of this
    wpmu memberships plugin comes close but still has issues after weeks of trying with their devs. Pretty much I do not see a current easy to use solution to this.

    • I find that very interesting.

      From what you say, I understand that you would like to grant access to a certain blog based on group membership. There are at least two perspectives that I can offer to that:

      1 – Grant access to the whole blog based on group membership
      2 – Grant access to a blog’s articles based on group capabilities

      With the current beta-1 you can do #2 but you can’t do #1 directly. To do #2 you simply protect all entries by the groups_read_post capability and assign that capability to the privileged group on each blog that you want to protect. For #1 it’s certainly something to consider and for #2 I’d say one would have to reduce the capabilities of the subscriber role and add those back on to the privileged group(s). Of course #1 would be much easier to handle on large deployments … actually I found myself wondering today why not allow to remove capabilities based on group membership because it might have come in handy on a project. Anyhow, if you’d like to try #2 and let me know about how it suits what you’re trying to achieve? There’s room for useful features …

      • shawn

        #1 would be much easier for larger systems. Having a simple blog url restriction rule that covers all the content on that particular blog for a certain group would be easy to handle.

        #2 becomes more difficult to maintain, esp as I am not just protecting posts, but custom post-types, taxonomies, forums, etc.

        well hope some of the ideas are valid.

        I’ve been on this journey for a few weeks now and frankly, there really isn’t an elegant solution available for multisite setups.

  • ricardo

    I could not get it to add capabilities (nothing would happen). What else is required?

    • How did you add the capability? If you did it on the Groups > Capabilities screen the capability has been added. Have you checked your filters on top?

  • iamjwk

    Played around with the plugin and have following feedback:
    1. Assigning capabilities to a group is time intensive; you have to assign capability for capability via the dropdown. Would be handy to have list of capabilities on the group edit screen in which the checkboxes can be ticked for required capabilities.

    2. Currently am not going to use this plugin although it looks very promising. Reason is that visibility of posts is completely dependent on the capability “groups_read_post”, while I would like to assign groups to the post, so I can for example make certain posts visible to family members only and not to friends. But each group would require the groups_read_post capability to make sure they can read other posts.

    • Thanks for trying it and sharing that :)
      Regarding 1 – if you want to assign multiple capabilities to groups it would really be a nice option to be able to do that.
      On 2 – I can see what you mean. It would make sense to be able to use your own choice of capabilities.

  • Hi Kento,

    We are a small consulting company and would like to have customer specific pages and posts on our site that would require a customer to login in order to see their specific content. Each customer will have a unique set of pages with information confidential to their business.

    Does your plugin sound like a fit for our use case?

    Two other questions:

    1. Is there a way to protect files so that customers can only download files specific to their group?

    2. Is protected content hidden from WordPress’s search results?

    Thank you!
    Bill

    • Hi Bill,

      Thanks for considering to work with Groups. Wouldn’t a multisite seem like the appropriate solution for this? You could add a site for each customer and protect its posts using the standard access restriction that Groups provides. This might even add prestige, as each site can reflect the customer’s corporate identity.

      Regarding the other questions:
      1 – Unless the files are protected by additional means, anyone who knows the file’s URL will be able to access it.
      2 – Yes.

      • Hi Kento,

        Thank you for your reply and your ideas. Re: Your Multi-Site suggestion: An excellent idea, but we’d like to keep all our content in a single site.

        We’ll give your plugin a shot and see how it works.

        Regards,
        Bill

  • Bob

    Can I get this to work with buddypress groups? double entry?

  • elvis

    Hi
    I am interested in using Groups, as I would like to group content for people to view but not limit access.
    For me i would really like
    1. php code in addition to the posting shortcodes (for more varied content)
    2. to be able to list ‘my groups’ for logged in user
    3. as iamjwk suggested above, I would need to add certain posts or categories to groups.

    I haven’t tried using ‘do_shortcode’ for point 1. but the other 2 are essential to me at the moment.
    It would be great to look into these if you are continuing to develop.
    thanks
    elvis

    • Thanks for your suggestions elvis, yes this is actively being developed further and what you propose makes sense to me as well. We can expect to see 2 and 3 done shortly and the documentation that is being prepared will help people to understand the API to integrate with their own projects.

  • Roger

    Hi, this is perfect for my needs…if I can get the shortcodes to work. If I want to have a bit of content appear for members and a suggestion to register appear for non-members, wouldn’t this be right?

    [groups_member group="1"]Here’s your content.[/groups_member]
    [groups_non_member group="1"]Please register.[/groups_non_member]

    This works to hide or show the first bit, but the “please register” message is never hidden, group members see it as well as non-group members (and not just administrators). This is on the latest version of WP.

    Also, I never seem to be able to unset the administrator override. Thanks for writing the plugin!

    • Could you try it like this please?


      [groups_member group="Registered"]

      This is visible to registered users only.

      [/groups_member]

      [groups_non_member group="Registered"]

      This is visible to non-registered users only.

      [/groups_non_member]

      I would say it’s either because the actual content is not on a new line (as in the example I give above) or it might have to do with the double quotes used (e.g. using right double quotes instead of normal double quotes).

      Hey also great to see this suits you, please let me know if the above solves it.

      Thanks also for mentioning the administrator override issue, this looks like a bug – will need to fix it ;)

  • Roger

    I switched to single quotes, though I was definitely using normal double quotes before, and it works. Yay! Thanks again.

  • I would like all users to be able to access all my site content but I would like to control the email announcements of blog posts.

    Example 1:
    Real-Time Group – Gets email notice as posts are published
    Daily Group – Gets email notice of new posts once a day
    Weekly Group – Gets email notice of new posts weekly

    Can I use Group to accomplish this?

  • Ben

    How can I use your plugin to hide an entire page? Example:

    All registered users can see Pages A, B, and C
    Members of Group A can see Pages D, E, F, and X as well
    Members of Group B can see Pages X, Y, and Z as well

    Would like to have the entire Page hidden so it appears in the site navigation for the appropriate users only.

    Thank you!

    • Thanks for the input Ben, in the current version 1.0.0-beta-3 Groups handles access to posts through the groups_read_post capability. This controls access to posts via back and front end but has its limitations – if a Group has the capability, its members can access any page that requires it. This is going to be changed so that cases like the one you describe can be covered easily as well.
      Meanwhile (it’s not the ideal but an option for your case) you could wrap the content of the pages in question within Groups’ [groups_member] shortcode. Most probably the next release will cover your case fully.

  • Hey there itthinx,

    Just installed the plugin, I am planning on using it to manage our Street Team. It is pretty redundant but I would like to be able to have a member be able to press a button and be automatically added to a certain group. Can this be done?

    Thanks!

    • Hi Peter,
      Yes you can do that through the API. Your button handler could end up adding the user to a group:
      Groups_User_Group::create( array( 'user_id' => $user_id, 'group_id' => $group_id ) );
      Hope that helps, Cheers!

Leave a comment

Your email address will not be published. Required fields are marked *

*


2 + = three