We've a large site running Drupal 7 with OG, Flag, Rules, etc.

OG uses a subscription model where you have to confirm you want to join a group (or leave a group) so we've decided to move to a Flag system that then uses rules to add (or remove) that user from the group.

All works great, except the site is already live and we have a lot of members in groups already, which obviously Flag doesn't recognise.

Is there a way to force Flag to check if a group subscription exists already?


I seem to understand from your question, that you're looking for a way to flag the existing members of an OG group.

If that's what you want, then a possible approach to make this work, is to process the results of a VBO enabled view via Rules, whereas your rule performs 2 Rules Actions:

  • load the VBO list of users (of an OG group) that you want to be processed.
  • add a loop to perform a Rules Action, whereas you just flag each user contained in your Views results.

For more details, have a look at the tutorial "How to process the results of a VBO enabled view via Rules?".

PS: if this is NOT what you want, by using this approach (anyway) I believe your question about "Is there a way to force Flag to check if a group subscription exists already?" became obsolete ...

| improve this answer | |
  • @studiocomms merci for the (first) feedback/comment. Just curious (for now) if I correctly understood (translated) your question. Did I? Ie that "you're looking for a way to flag the existing members of an OG group."? – Pierre.Vriens Nov 25 '16 at 14:50
  • I think so. We need to change the new flag of group subscription for existing members of an OG group. So previously, group subscriptions we're done using OG on it's own. Now we're using a Flag (group_membership) but currently this flag doesn't know if the user is a member of a group already. Hope that makes sense! – studiocomms Nov 25 '16 at 15:20
  • Hi Pierre, apologies for the slow reply, away for the weekend. We're still struggling to get the VBO to work, it just constantly times-out (AJAX errors). Having looked around here and the Drupal forums/bugs it looks like quite a common problem. Would be a 10 minutes job if we could get it to work :) – studiocomms Nov 28 '16 at 14:26
  • Thanks Pierre, I have added a follow up question drupal.stackexchange.com/questions/221630/… – studiocomms Nov 28 '16 at 15:52
  • Our view is filtered to display a list of users from a group that has 30 members. Looks like the Ajax error is stopping us from making progress. – studiocomms Nov 28 '16 at 16:43

Guess what, if for some reason (such as this one), you can't get it to work with the prior answer, then you may want to try an approach which is like "the other way around". Read on for more details on that approach ...

Step 1

Start with creating an extremely basic Rules Component, which includes whatever Rules Conditions you might need (if any), and with a Rules Action to flag (using the Flag module) a user, whereas you specify the user to be flagged as a parameter for that Rules Component. FYI: this is really like a getting started with Rules ...

Step 2

Create a view of your existing members of an OG group that you want to be flagged. Maybe you already have such view that you can use. Then transform that view into a view that uses Views Bulk Operations, and use the technique documented in "How to use Rules to create a custom bulk operation for a VBO view?".

In doing so, you'll then be able to use Rules Components (using the Rules module), in which you can then include the required logic to flag a single user with your flag. If you wonder how to create such Rule that would fit your VBO view (ie that you can use in it), then use this link ...


Even though one may think "Hm, is it really that easy?", it happens that after you created a Rules Component and try to use it in a VBO view, that Rules Component cannot be selected as an operation to be enabled in your VBO view. If that happens, and you wonder what it would take to try to make it show up anyway (in the VBO view), then use this link ...

| improve this answer | |
  • Looking back, i think we have caused confusion. I don't think we want to flag our users, we want users to flag a flag. We have a flag for nodes called subscribe_og. From now users click that to join, or leave, a group. If you are not a member of the group, the flag says 'Join'. If you are a member the flag says 'leave'. Old members of a group currently see 'leave' as they have not clicked a flag. Is it possible to use a views and rules to generate a list of group members, check if they have have activated the node flag, and if not, activate the node flag for them. – studiocomms Dec 1 '16 at 11:36
  • 1
    @studiocomms Interesting evolution ... IMO it's not really that you have caused confusion, but rather that you are changing your mind, which is fine. To the extend that you don't change the original question (like this one here), to avoid it would invalidate existing answers. I suggest you create a new question, if appropriate with a link to this one (or any other one), and then include the relevant parts from your prior comment. That will also create a lot of new space to post an appropriate (new) answer. Ps: now more news about the AJAX issue? – Pierre.Vriens Dec 1 '16 at 11:42
  • I totally agree, thanks for your help. New question here - drupal.stackexchange.com/questions/221906/… – studiocomms Dec 1 '16 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.