groupby - How to register a user to a group by an invitation code?

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 c

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.

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.

Share Improve this question edited Aug 26, 2013 at 18:15 Iurie asked Aug 25, 2013 at 12:31 IurieIurie 1,1314 gold badges25 silver badges46 bronze badges 4
  • How are you grouping users? Are you using a plugin? – Charles Clarkson Commented Aug 25, 2013 at 20:47
  • @charles-clarkson I have improved the question. – Iurie Commented Aug 26, 2013 at 17:52
  • Plugin suggestions are off-topic, have a look at wordpress.stackexchange/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
Add a comment  | 

2 Answers 2

Reset to default 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);
    }
}

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

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745526959a4631513.html

相关推荐

  • groupby - How to register a user to a group by an invitation code?

    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 c

    16小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信