Recent Topics

1 May 30, 2008 19:44    

I would like to put new users into specific groups instead of all going into a default group. So I start with DisplayRegisterFormFieldset to make some new form fields on registration. A select box to pick which group you'll end up in an a text field to provide 'proof' that you belong in that group. Basically the text field will be used to say "if they got the right answer then give them the group they picked else use the default group".

BTW I am hard-coding the group options instead of programically displaying a list of groups because no one gets to register into the Admin group, but that is probably OT ... which might be a new record for how early I go off topic in my own thread. :roll:

Okay so I poke around the documentation a bit and see that AppendUserRegistrTransact will be my friend if I can figure out how to use it. It says in inc/plugins/_plugin.class.php:

* If you want to modify the about-to-be-created user (if the transaction gets
* committed), you'll have to call {@link User::dbupdate()} on it, because he
* got already inserted (but the transaction is not yet committed).

Unfortunately without an example of a plugin doing this, figuring it out is not something I'll be successful at. Doubly unfortunately, OpenID plugin uses AppendUserRegistrTransact which means I have to somehow figure out the workings of a true genius :(

IT SEEMS that

$params['User']->set( 'firstname', $match[1] );
$params['User']->set( 'lastname', $match[2] );
$params['User']->dbsave();

is modifying a User, but is this really a registrant? Is this way of doing business all I need to set a specific group for a new registrant? I think of OpenID as a commenting thing but maybe it also applies to new registrants? Obviously I would not be using firstname and lastname when I want to change the group ID... Probably something like $params['User']->set( 'user_grp_ID', 42 ); would be more appropriate?

Anyway yeah help desired, please.

2 May 30, 2008 20:41

Ok this is totally off the top of my head, so I could be bollocks wrong ... mind you, I'm often bollocks wrong this early in a post, so that's no achievement :roll:

I have a feeling that you're going to need to do something like :

$h20_deficient = get_Cache( 'GroupCache' );
$luckily_I_have_beer = $h20_deficient->get_by_ID( 'your_group_ID' );
$params['User']->set_Group( $luckily_I_have_beer );

¥

3 May 30, 2008 21:03

Cool. Will test it out pretty soon. Trying still to finish up some mindlessly stupid work on older plugins, then want to get this project running.


Form is loading...