By esadot on
Hi,
I’d like to force my new users to select a group during the registration process. Groups are advertised at the registration form, and I need the registration “submit” button to be inactive until the user select (at least) one group.
og_mandatory_group module is not an adequate solution here, since I don’t have a need for one default group.
Any advice would be welcome
Thanks in advance
Comments
I don't know off the top of
I don't know off the top of my head if you can *force* a user to choose a group, but you can restrict the ability to create content outside of groups.
Cheers,
Bill
-------
http://www.funnymonkey.com
Tools for Teachers
-------
http://www.funnymonkey.com
Appreciated Bill
Appreciated Bill, but my site interest lies in having users choosing the *right* group. Having a user register without choosing a group misses the all purpose.
Again, thank for the tip.
In thinking about this a
In thinking about this a little more, you might want to think about extending the functionality of the existing og_mandatory_group module, as this comes the closest to matching the functionality you want --
I don't think this is something that can be accomplished (or even kludged) as you describe without writing some additional code.
Cheers,
Bill
-------
http://www.funnymonkey.com
Tools for Teachers
-------
http://www.funnymonkey.com
Again, thank you Bill
Again, thank you Bill.
Yes, that was my thought initially, to work on the og_mandatory_group module as it seems as the best fit (particularly, as the name accommodate what I want to achieve
My coding skills are rusty, so I thought to seek advice first.
Sorry for going off-topic
... but while it seems a simple thing to restrict the ability to create content outside of groups, I can't find any description of how to do this. Can you point me in the right direction?
NEVERMIND.... I think I figured it out.
When you say you need the
When you say you need the submit button to be inactive until a group is chosen, doesn't that imply a JavaScript solution on the client, instead of a PHP/Drupal solution on the server? You might still have to do something in the Drupal theme to associate an event handler with each of the group selection boxes, as well as loading the .js (if you go down that path).
Gary Feldman
Thanks Gary
Thanks Gary, the “inactive” was only a figure of speech (and I apologize for stealing Cpu cycles for that). I meant that the registration will fail if the user had not selected a group. That could be done (and probably should be done) in the same manner it fails today when the user omits the username or email address.
Thank you.
Well, I can't give you a
Well, I can't give you a complete answer for implementing it that way, but I'd start by looking at the _validate hooks.
Gary Feldman
Thank you Gary
Thank you Gary, I definitely will take a look.
hook_form_alter -> validate
Well, if og_mandatory_group isn't doing everything, sounds like (as suggested above) you need to do an extra validation on the form. Use hook_form_alter to add an extra validation function onto the user registration form and then set a form_error if no groups are checked. Probalby niceer if also you mention somewhere that a group selection is required....
---
Work: BioRAFT
The actual validation gives me a hard time
Thanks.
I guess I can handle the hook_form_alter function, and the corresponded error message.
On the other hand, I have no idea where to start with the actual validation - any idea / directives as of where to look, and what to look for, in order to confirm that at least one group is checked at the registration form?
Thanks in advance
form definition
Looks like here's where the relevant part of the registration form is defined:
So i'd think your validation function would need to look something like (this is totally untested):
---
Work: BioRAFT
How do I invoke the mymodule_registration_validate function?
Thanks.
How do I invoke the mymodule_registration_validate function?
You must implement either
You must implement either hook_form_alter or hook_user, and then add the validation function to the form. See the Froms API reference:
http://api.drupal.org/api/4.7/file/developer/topics/forms_api_reference....
here are a couple examples (line number after module name):
modules/node.module:2215:
$form['#validate']['node_search_validate'] = array();modules/system.module:78:
So you want to do something like this:
$form['og_register']['og_register']['#validate'] = array('mymodule_registration_validate' => array());---
Work: BioRAFT
It seems to work, at least at a first glance
Thanks a million. It seems to work, at least at a first glance.
I worked at the og.module, although I think that og_mandatory_group module would be the best candidate.
First let see if it looks ok to the experts.
1. I added the validation function to the registration form at the end of the “registration” case in the og_user function.
2. I added the actual validation function at the button of og.module.
ok - but
Ok, that's good to get it working, but not the best idea for the long run. If you make your own (very small) module to do the same work, it'll make you life much easier when OG is updated.
As an alternative, I'm the current maintainer for og_mandatory_group (even though I'm not actually using it at the moment). If you want to put this in as a feature request (plus patch or at least some code) we can work on it together.
---
Work: BioRAFT
It seems like we have a plan in place
og_mandatory_group, definitely. It seems like we have a plan in place, great.
May I suggest we work of-line for a while, and post back to the benefit of the community upon having a more solid version.
post a feature request
Please post a feature request - that's the easiest way for me to track it, though we can also discuss directly:
http://drupal.org/node/add/project_issue/og_mandatory_group/feature
---
Work: BioRAFT
Feature request been added
http://drupal.org/node/85440
I can't see the function
I can't see the function “force user to select a group upon registration" in version 6.x.
Can anyone point me that how to use it in version 6? or the function has been discarded.
thanks
meg