I use the node registration module to register users to events.
I want even anonymous users to register (and thus changing the drupal permissions I can do this).
I created a rule that "for each saved registration node" creates a user type entity.
But I can not contextually create the node registration and create the user to edit the fields in the node_registration uid and author_uid table going to insert the uid of the newly created user.
So I find myself a user with username username@mail.com,
a node registration with the mail username@mail.com
and I can not bind them together because the row in the node_registration table is uid = 0 author_uid = 0
I managed to solve by scheduling a component that makes the update_query on the database, but it does not seem to me the correct way
Did you have the same problem?
Comments
Comment #2
lucavox commentedComment #3
rudiedirkx commentedYou're creating users from anonymous registrations..? Kewl.
I don't know Rules very well... It's probably much easier with custom code. You can use the node registration 'presave' hook to make a user AND update the registration's uid.
I don't know how to Rules it. Maybe ask on drupal SE or in a Drupal group?
Comment #4
lucavox commentedthanks! rudiedirkx
can you tell me the context of this hook?
verifying in node_registration.api.php I find
* Implements hook_node_registration_presave ().
* /
function hook_node_registration_presave ($ registration) {
}
but it would seem that I can not intercept
* Implements hook_node_registration_presave ().
* /
function hook_node_registration_presave ($ registration) {
dpm ($ registration);
}
Comment #5
rudiedirkx commentedIntercept? You want the registration to be created, and a user, right?
So create the user in that hook using the registration data in $registration, and then put the new uid in $registration->uid.
The context is the registration... I don't know what you mean. It's called just before saving the registration into the db, so you can't stop it anymore, but you can alter its values before it's inserted.
Don't forget to check if it's a new registration, not an existing:
if (empty($registration->registration_id))
Does that help?
Comment #6
rudiedirkx commentedAh, now I get it. You didn't rename the function. The
hook_prefix is a Drupal api standard, but not what the function should be called. You have to create a module, let's say abc_def and then rename the hook function: 'hook' becomes the module machine name, so the function ne becomesabc_def_node_registration_presaveDid that help?
Comment #7
lucavox commented#6
It was very useful and I thank you!
but now, unfortunately, another problem has arisen!
When I create a user in presave, then I do not validate the node registration from anonymous because it tells me that there is already a mail like that of node registration