0

I'm working on a site where I'd like anyone to be able to sign up, but people who sign up with an invitation code would automatically be registered to an existing group associated with that code. How can I do this?

I have not yet chosen how groups will be created, but I know that this can be done with one of these plugins: Groups, User Groups or Simple Groups. The same with invitation codes, there are very good plugins for this: CM Invitation Codes, Register Plus Redux or Pie Register. What is missing is an intermediate tool (code/function) that will associate some groups with some invitation codes.

4
  • How are you grouping users? Are you using a plugin? Commented Aug 25, 2013 at 20:47
  • @charles-clarkson I have improved the question.
    – Yuri
    Commented Aug 26, 2013 at 17:52
  • Plugin suggestions are off-topic, have a look at wordpress.stackexchange.com/help
    – Wyck
    Commented Aug 26, 2013 at 17:54
  • Opinion questions are also off-topic, have a look at the ^link.
    – Wyck
    Commented Aug 26, 2013 at 17:57

2 Answers 2

2

Not sure how you want to handle groups, but it could just be user_meta.

Regardless, you could use Gravity Forms + user registration add-on to process a user registration and determine what group the user should be added to. This should work even if you are using third-party hooks.

If it's simple user_meta, you can just check for that wherever you want to limit membership, and avoid stacking up tons of third party plugins.

Here is an example.

// assign group based on code input
add_action('gform_after_submission', 'the_grouper', 10, 2);
function the_grouper($entry, $form){
    $current_user = wp_get_current_user();
    $current_user_id = $current_user->ID;

    switch $entry['group_code'] {
        case 'CODE_123' :
            $group = 'group_123';
            break;

        case 'CODE_ABC' :
            $group = 'group_abc';
            break;
        // etc

        default:
            $group = false;
            break;
    }

    if($group){
        update_metadata('user', $current_user_id, 'the_group', $group);
    }
}
3
  • Your example can be used only with Gravity Forms? Unfortunately, I can not use paid plugins :(.
    – Yuri
    Commented Aug 28, 2013 at 9:10
  • Well, if you know PHP, you can adapt the same answer to a regular form.
    – GhostToast
    Commented Aug 28, 2013 at 13:18
  • This is not about me :(. But I will try to find a solution. Thank you!
    – Yuri
    Commented Aug 28, 2013 at 14:58
0

This is what you need! A simple solution...

http://codecanyon.net/item/gravity-forms-invitation-codes/11441758

1
  • Link only answers are not quite recommended. Moreover your answer is like ad of the plugin. Commented May 22, 2015 at 2:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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