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
2 Answers
Reset to default 2Not 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
评论列表(0条)