On my user register form I have a checkbox that let's the user choose if he wants to have a content type for his profile.
So if he does not check that checkbox I don't want to create a node of that content type for his profile.
The solution i came up with is:
I have a validation function that checks if that checkbox is checked, and if not, i unset the data for that node.
<?php unset($form_state['content_profile_registration']['optional_content_type']['node']); ?>
But the submit function of the content_profile_registration module tries to save the node of that content type despite the fact that there is no data resulting in some warnings...
So i just added an if clause that checks if there is data for that content type, and ignore ot if there is none.
<?php
function content_profile_registration_user_register_submit($form, &$form_state) {
foreach (content_profile_get_types('names', 'registration_use') as $type => $typename) {
if($node = &$form_state['content_profile_registration'][$type]['node']) {
// Set user's information for the node.
...........
// Create the node.
...........
}
}
}
?>
This is a minor, unintrusive change that, in my oppinion, could be usefull. If the maintainers of this module agree, this patch could be merged into HEAD
| Comment | File | Size | Author |
|---|---|---|---|
| content_profile_registration-1.patch | 1.27 KB | DizzyC |
Comments
Comment #1
jgraham commentedThanks for the patch, it has been merged.
This is exactly the kind of thing that this and the parent module should be addressing as this enables helper modules to do any necessary adjustments of the base behavior.
Comment #2
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.