Groups Gravity Forms remove from group

I need to know if your plugin GROUPS GRAVITY FORMS allows a user sending the form to also be REMOVED from specified groups, much like with the Groups Woocommerce plugin.

In those instances when I want users to join a new group but no longer from a previous one he belonged to.

For example: when user joins Silver (free) he gets removed from Bronze (also free).

I’d just like to know this before I buy your add on plugin for Gravity Forms.

thanks

P.S. I couldn’t get your “join group” shortcode to work, the button doesn’t show up. I’m running latest versions of WP, Buddypress, Groups, Beaver Builder, Learndash and others. Any tips?

28 Responses to Groups Gravity Forms remove from group

  1. George October 5, 2017 at 7:35 am #

    Hi Stefano,

    This can be done with an action hook.
    To be more specific, if you use groups_created_user_group action, when the user will be added to Silver group from a gravity form submission, you will check if the user belongs to Bronze and remove him.

    If all the users should be removed from Bronze group, it is straightforward, otherwise if you want to remove the user from the previous group he belongs to, then you have to get the group he belongs to and then remove the user.

    If you can’t implement it by yourself, please let me know so i can help you.

    Regarding the shortcode button if you are referring to [groups_join group="X"], make sure that the X group exists and if Beaver Builder requires a special setting for processing shortcodes. Otherwise, enable WP debugging, visit the page containing the shortcode and check debug.log for errors.

    Kind regards,
    George

  2. Stefano October 5, 2017 at 1:20 pm #

    Hi George,

    in my case, the best case scenario with the plugin is that when making a form I can specify which group the user will be added to, and which group he shall be removed from, if in fact he belongs to that group.

    The example I’ve seen already implemented is in the Groups Woocommerce plugin which I’ve used. When a user purchases a product he gets added to a group and removed from the groups that I specify. That logic makes sense to me and fits my new project well.

    When I get the Groups Gravity Forms one of these next few days I’ll gladly ask for assistance with hooks etc, I’m not a programmer at all.

    Thanks for your help!

  3. George October 5, 2017 at 4:20 pm #

    Hi Stefano,

    You are welcome.
    The groups you choose to add to and remove the user from are personal choices or have to do with the group that the user currently belongs to? I’m asking that just to gather more info on how the filter should be implemented and if the user removal can be further automated.

    Cheers,
    George

  4. Stefano October 5, 2017 at 4:45 pm #

    In my project, the user can sign up for many different groups and belong to them simultaneously, EXCEPT some cases where the situation is more like “membership levels”. In this case if he belongs to Bronze and is moving up to Silver or Gold, I want to take him out of Bronze while leaving him in other groups. There are cases when a user is not in Bronze and signs up directly for Silver, in which case its redundant.

    I find this useful because I also use the Groups Mailchimp add on, and group members get assigned to groups/segments in Mailchimp automatically where I can handle communications easily.

  5. Stefano October 5, 2017 at 4:51 pm #

    when creating a form specifically for membership level enrollment, I would set:

    IF FOR SILVER ENROLLMENT:

    Add to group: Silver
    Remove from group: Bronze; Gold

    IF FOR GOLD ENROLLMENT:

    Add to group: Gold
    Remove from group: Bronze; Silver

    IF FOR BRONZE ENROLLMENT:

    Add to group: Bronze
    Remove from group: Silver; Gold

    This would just make sure that a user is only ever in one of these 3 groups at any specific time, while other group memberships wouldn’t be touched.

    So I can use Gravity Forms for all of my group enrollments needs, including the main membership types.

  6. Stefano October 6, 2017 at 12:03 am #

    Hi George,

    I went ahead and purchased your Groups Gravity Forms plugin, along with GF.

    I hope you can help me get that extra functionality working.

    thanks, and all the best…

  7. George October 9, 2017 at 10:00 am #

    Hi Stefano,

    Thanks for the info.
    I’m already implementing a custom plugin to support this. Once it is ready i’ll let you know.

    Cheers,
    George

  8. George October 9, 2017 at 11:57 am #

    Hi Stefano,

    I’ve just emailed you the custom plugin called Groups Switch User.
    The plugin supports three groups and i used Gold, Silver, Bronze. If you wish to use other groups though, you can define their names where you see the groups above. These are the lines for $first_group_name, $second_group_name and $third_group_name where you should use the names of the desired groups.

    I would suggest you to first try it with a test user like this:
    1) Add a test user
    2) Add the user to the Gold, Silver groups.
    3) Add the user to the Bronze group. etc

    The process i mentioned above can be done quickly for your tests, in your Dashboard under Users. There, you should:
    1) select the test user,
    2) Choose groups to add him,
    3) select Add to group from Group Actions and
    4) press the Apply button.

    If you have further questions, please reply here.

    Cheers,
    George

  9. Stefano October 9, 2017 at 12:09 pm #

    Thanks George, that’s really good news. I’ll test it out today and let you know.

    cheers,
    Stefano

  10. Stefano October 9, 2017 at 12:12 pm #

    Is this a plugin to be added to my plugins folder first?

  11. George October 9, 2017 at 1:34 pm #

    Hi Stefano,

    In your Dashboard, go to Plugins > Add new and then choose to upload, with Upload plugin button to the top of the page.

    Cheers

  12. Stefano October 9, 2017 at 2:55 pm #

    Ok, it seems to be working properly.

    If I want to add more groups of this type to the mix, is there an easy way to do this myself? Or could you add about 3 more “inert” group types that I can change as I add groups when needed? If they can exist without consequence until I activate them by changing there names, that would allow me to expand to 6 main group types without need for assistance.

    My suggestion for a feature would be to replicate the functionality existing in the Groups Woocommerce plugin: when I create a “Product” I can select which groups to add the customer to, and which to remove him from, in the Groups Tab on the new product page. When the purchase is complete the customer is added to/removed from the groups specified. This give me a lot more flexibility when creating Gravity Forms for various purposes in my site.

    Thanks for your valuable assistance, I love your Groups products. After trying out many different membership solutions I’ve come back to yours for this project mainly for the simplicity and flexibility.

    Ciao,
    Stefano

  13. George October 10, 2017 at 9:21 am #

    Perhaps it’s better for me to modify the structure and make it accept more groups.
    The main concept though will remain the same i guess? If we have 5 groups, a user is member in the 4 of them, once he is added to the 5th group, he gets removed from the other 4.

    Please let me know, so that i can do the modifications necessary.

    Cheers,
    George

  14. Stefano October 10, 2017 at 10:29 am #

    yes, 5 or even 6 groups will be enough (Type A groups). It should work in all directions though: when a user is a member of any single Type A group, by joining a different one of these 6 special groups he is removed from the other 5. So, a user can only be a member of one of these 6 Type A groups at any time, but can move up or down the scale of 1-6. Other groups would not be affected by this switching. This means that there would be Type A groups 1-6, and an unlimited number of Type B groups which a member can join and be enrolled in simultaneously which are not affected by switching between the Type A groups, UNLESS a Type B group is set up as a sub-group of a Type A group (and therefore inherits its restrictions).

    Is this a plausible scenario?

  15. George October 11, 2017 at 9:42 am #

    Yes it is Stefano 馃檪

    I’ve updated the plugin and now you can set the desired list of groups. Once, a user is added to all of them, remains a member of the last-added group and is being removed from the rest of the groups.
    Regarding how to add the list of the desired groups, here is an example function below:
    add_filter( 'groups_switch_user_groups_list', 'gsu_groups_list' );
    function gsu_groups_list( $groups ) {
    return array( 'Gold', 'Silver', 'Bronze' );
    }

    which you should copy/paste in your functions.php of your child theme( if it exists), otherwise of your main theme. If you don’t set the list of groups, the plugin does nothing.

    IMPORTANT: You should delete the previous version and install the one i’ve just sent you.

    Cheers,
    George

  16. Stefano October 11, 2017 at 11:31 am #

    Fabulous!

    ok, so I’ve deleted the previous plugin, and installed the new one. Now I’m looking at the plugin code in WP admin under Plugins > Editor, and I see this:

    groups_list = array( ‘Gold’, ‘Silver’, ‘Bronze’, ‘Blue’ ); I should change the names of these groups in the editor, yes?

    THEN,

    I should add the code in your message above to my child theme’s functions.php folder, with the corresponding group names, through the Appearance > Editor > Functions.php. Correct?

    thanks

  17. George October 11, 2017 at 11:40 am #

    Hi Stefano,

    In this version there is nothing to edit in the plugin file, i did it mostly to avoid false entries, missing quotes etc.
    The only way to set the list of your groups is by using the snippet i added on my previous comment. You should only modify this line:
    return array( ‘Gold’, ‘Silver’, ‘Bronze’ );
    and replace Gold, Silver, Bronze with your group names. Each name should be quoted, ie ‘Gold’ is correct, Gold is not correct and make sure that you use existing group names, otherwise the plugin would have no effect at all.

    Cheers,
    George

  18. Stefano October 11, 2017 at 12:11 pm #

    All clear, thanks.

    And I could add more groups to this line when I decide to create more special levels, correct? As many as I need?

  19. Stefano October 11, 2017 at 12:39 pm #

    I’m testing now. So far, the plugin is not working correctly… the groups are not being removed when the user registers for a different group.

    I’ve checked that the groups are existing, the spelling is correct, and they are specified in the code in functions.php.

    User registers ok for his first group, but when he later registers for a different group from the list he is not removed from the first group.

    Any ideas?

  20. George October 11, 2017 at 1:27 pm #

    Hi Stefano,

    I have tested it with maximum 6 groups, but it shouldn’t have a problem.

    In general, the plugin works with the list specified. The user gets added to each of the groups specified and when is added to the last group( regardless of order), gets removed from the rest of them. This is why i asked on my previous comment if the basic concept would be the same.

    If you want to switch between two groups, i.e the user is member of Gold and then becomes a member of Silver, in order for the switch to be successful you have to add only Gold and Silver in the return array of the function hook.

    If though, you need to specify separate rules, then it needs a modification.
    For example:
    1) First groups list is ( Gold, Silver, Bronze ).
    2) Second groups list is ( Red, Green, Blue ).
    If we want to “promote” the user based on which groups list gets “completed”, but keep the rest of the memberships active, then a few additions are required.

    Also, if we want to promote the user with a specific order this should be noted as well.
    For example:
    1) Become a member of Bronze,
    2) then Silver,
    3) and if the user becomes a member of Gold as well, then remove the user from the rest of groups.

    Hope the aforementioned cover your case.
    If there is a feature i’m missing you are welcome to mention it.

    Kind regards,
    George

  21. Stefano October 11, 2017 at 2:24 pm #

    Here’s what the basic functionality will be:

    A new user completes a course (LearnDash) and is shown the Gravity Form for joining ‘Bronze’, and he completes the form and joins.

    The same user later completes a new course and is now invited to join ‘Silver’ with a Gravity Form. When he does, he is added to ‘Silver’ and removed from ‘Bronze’.

    A third course is available and if he chooses to complete that one too, again he is invited to join ‘Gold’ with a Form. When he does, he is added to ‘Gold’ and removed from ‘Silver’.

    As a security measure I was thinking that it would be good if a user is removed from all other Type A groups (Bronze, Silver, Gold) listed in the return array when he completes any of these forms I make available. In those forms right now I can only select the single Type A group that he will be joining by sending the form. With your script, it should simply be an automatic action that any group in the list different from the one he is currently joining be deactivated from his account.

    Each of these “Type A” groups will have different menu items and content available, based on the kind of activity the user will be allowed to engage in. For example, by joining Silver he no longer has access to the content for Bronze.

    I had imagined that the easiest solution would be to replicate the Groups Woocommerce functionality in the Groups Gravity Forms plugin, but I am as ignorant of code as I am of nuclear physics so I leave it to you to determine how best to get the desired results. 馃檪

    Does that help clarify what I’m looking for?

    Btw, I’m testing your Affiliates plugin and when I’m more advanced in this project I’ll probably get the Enterprise solution.

    Thanks for all your help.

  22. George October 12, 2017 at 8:46 am #

    Hi Stefano,

    Are there any other Type A groups?
    I mean other than Gold, Silver, Bronze where the user should still be a member while promoting, or not?

    Cheers
    George

  23. Stefano October 12, 2017 at 9:21 am #

    Hi George,

    It hadn’t occurred to me before, but this is much like a typical membership plugin where you can only belong to one level at a time, adding to that however also the possibility of multiple levels, in a kind of hybrid model:

    Type A groups 1-6 (Red, Blue, Bronze, Silver, Gold, Platinum): switch between these freely, but not belong to more than one at a time.

    Type B groups (infinite number): user can join as many as he wants simultaneously – ie. bbPress Forum Categories, special BP groups, some other plugin functionalities like MinervaKB, etc.

    I could probably get this solution by installing Paid Memberships Pro alongside Groups. If it made life easier I can try that before taking more of your time for special modifications. Tell me if you agree.

    thanks,

  24. George October 12, 2017 at 10:21 am #

    Hi Stefano,

    Thanks for the explanation.
    The key point in that implementation is that you want each member to belong to a single group every time. This point is actually easier to implement than what is currently supported.

    Long story short, once i prepare it, i will send you a copy.

    Cheers,
    George

  25. Stefano October 12, 2017 at 11:23 am #

    great 馃檪

    just as a last attempt to clarify:

    user in Silver moves to Gold, losing Silver.
    user in Gold moves to Silver, losing Gold.

    But at the same time:

    user in Silver joins “Diamond” (a Type B group) but stays in Silver.
    user in Bronze joins Diamond, Ruby, Amethist and Topaz and stays in Bronze. When he moves to Silver he stays in all his Type B groups but loses Bronze.

    We can set up now about 6 Type A groups that probably will never need to be changed.

    Then, as I develop the project and keep adding functionality and complexity, I can add Type B groups at will with no need to do any coding.

    Using Gravity Forms for all the group enrolments, I’ll know which groups are A and which are B and set the parameters accordingly in your integration settings.

    thanks again!

  26. George October 13, 2017 at 7:03 am #

    You are welcome Stefano.

    I took these into account as well.
    Hope everything is right now but if not, don’t hesitate to contact me.

    Cheers,
    George

  27. Stefano October 13, 2017 at 11:38 am #

    Hi George,

    I’ve done some testing and it appears to all work perfectly! Hurray hurray! I’ll do more in depth testing over the next few days and get back to you on that.

    Thanks again, I am so happy with your products and the generous service you’ve rendered.

    I’ll have a few more questions as I begin setting up Affiliates but I’ll start a new topic for those.

    Also, I’ll ask you about using Groups with Buddypress and how to restrict the various functionalities within.

    With gratitude,

    Stefano

  28. George October 16, 2017 at 10:59 am #

    That’s great Stefano!

    Thank you for your time and i hope you enjoy our plugins.

    Cheers,
    George