User Registration - Any Variables? Help?

Permalink
I need the function where a user, when registering, can specify the group that he/she will be registering under. More specifically (and what I really need); I need a function where the admin can place specific login blocks that only allow users to register under a specific group.

Is this in any way possible with the given tools?

Also, Anyone successful with a pay-per-view content system with C5? This would be huge (it's what I'm attempting to assemble)

Thanks everyone for the everlasting forum response!

dlloyd
View Replies: View Best Answer
cyandesigns replied on at Permalink Reply
Did you ever have luck configuring c5 to allow someone who registers to choose which group they will register under?

Right now I have an attribute set up with the same names as the groups (which makes it easy to figure out which group the member should belong to) but i would love for this to automatically assign them to that group upon registration.

Any help would be greatly appreciated!!
brabin replied on at Permalink Reply
Did you ever get an answer to this question? I'm trying to do the same thing.
mnakalay replied on at Permalink Reply
mnakalay
Hello,
I am not quite clear on what you are trying to do.
Are you trying to allow users to select group when they register, or let the admin make that choice?
brabin replied on at Permalink Reply
I want users to be able to self-assign to the group they will register within, by virtue of selecting from among the attributes that I've created and also listed on the registration form as checkboxes.

I'd appreciate any help, thanks.
mnakalay replied on at Permalink Reply
mnakalay
You could look at the following free add-on, it will put you on the right path
http://www.concrete5.org/marketplace/addons/registrant-group/...
brabin replied on at Permalink Reply
Thanks, I did find that add-on and was reading this thread:
http://www.concrete5.org/community/forums/customizing_c5/place-new-...

It appears the add-on will allow you to assign users to a single group for all registrations that take place per-page, and there is some discussion of the code that would need to be used to allow for selection among multiple groups, but I'm afraid the code manipulation required is beyond my skill level. I was hoping someone had previously solved this problem and maybe I just hadn't found the post.

I've also purchased the Register User Pro Addon:
http://www.concrete5.org/marketplace/addons/register-user-pro/...

which allows you to customize on a block-by-block basis, including the ability to assign to a user group, but again, no way as far as I can tell to assign to a selected group from among multiple groups.
mnakalay replied on at Permalink Best Answer Reply
mnakalay
I see what you want to do.

I have a solution but you will need to overwrite Register User Pro's controller meaning if you update it later on, and the controller has been updated, the updates won't apply unless you copy the new controller file to the override place and write the modifications again.

Anyway.

First, copy the file ROOT/packages/jb_register/blocks/jb_register/controller.php and paste it in ROOT/blocks/jb_register/ (you need to create the directory jb_register in the root blocks directory)
That's your override. Open that file to make modifications to it.

Around line 263 look for
if($this->addToUserGroup){

a few lines under that find the following lines:
//get new user ID
$userID = $process->getUserID();
//add to user group
$u = User::getByUserID($userID);

cut (not copy) them and paste them just before the first line of code I mentioned so you have:
//get new user ID
$userID = $process->getUserID();
//add to user group
$u = User::getByUserID($userID);
if($this->addToUserGroup){


Just a bit below that look for:
$group = Group::getByID($this->addToUserGroup);
    $u->enterGroup($group);
}

Just after the final bracket add:
$group = Group::getByName($data['userGroup']);
$u->enterGroup($group);

So now you have:
$group = Group::getByID($this->addToUserGroup);
    $u->enterGroup($group);
}
$group = Group::getByName($data['userGroup']);
$u->enterGroup($group);


You can save now.

Still in the same ROOT/blocks/jb_register directory, create a new directory called templates. Now go back to find the file ROOT/packages/jb_register/blocks/jb_register/view.php. Copy it (not cut) and paste it inside the templates directory you just created.
Rename it to user_selected_group.php.
Open it to modify it.
Around line 274 you will see
<div class="control-group">
<?php echo $form->label('uPasswordConfirm',t('Confirm Password')); ?>
<div class="controls">
<?php echo $form->password('uPasswordConfirm'); ?>
</div>
</div>

just under that write:
<div class="control-group">
<?php echo $form->label('userGroup',t('Choose a group')); ?>
<div class="controls">
<select name="userGroup">
<option value="group_name1">group_name1</option>
<option value="group_name2"group_name2</option>
<option value="group_name3"group_name3</option>
</select>
</div>
</div>

Notice the pieces of text "group_name1", "group_name2", and "group_name3" each appearing twice? You need to replace them with the names of your groups properly spelled (respecting the case as well)
You can add or remove option lines as needed by just duplicating the existing ones.

When that's done, just save.
Now go to your page where the registration block is, put the page in edit mode, click the block, select templates and from the list of templates select "User Selected Group" and apply. Save.

Now you will see an added list just under your second password field.
Try to register, it should work.
brabin replied on at Permalink Reply
Very kind, thank you for your help mnakalay! I'll give this a try. I'll report back and if it works, I'll contact jb1 to see if he wants to incorporate it into his add-on in a future update.
FatTony1952 replied on at Permalink Reply
FatTony1952
I gave this a shot and although it registered the user, it did not add them to a group.
mnakalay replied on at Permalink Reply
mnakalay
All I can say is that I tried the code on the add-on before posting here and it worked.
FatTony1952 replied on at Permalink Reply
FatTony1952
Had to clear my cache first. All is good now. Thanks!