Claim on registration
Component ID
2833899
Component name
Claim on registration
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Downloads
175
Component created
Component changed
Component body
About
Allows anonymous users to create content and then automatically claim it upon successful registration.
Inspired by
Create and register for Drupal 7.
Configuration
- Go to admin/config/claim-on-registration or Configuration > Content authoring > Claim on registration.
- Select your content Types. Note you must enable the create content type permission for the selected content types for anonymous users.
- Enter Your cookie expiry value.
- Enter your cookie name.
- Save.
Process
- Anonymous user creates a content which you set permission for.
The module simply sets a cookie to with the new id, or appends the cookie if the anonymous creates multiple - The user registers or logs in.
- The created node(s) will be assigned to the user after logging in or registration.
- At this point when the user is assigned the content this module provides a hook which passes the node object with the updated user id.
- You may use this hook to handle any custom configurations you may require.
Example hook usage
/**
* Implements hook_claim_on_registration_node_update().
*/
function MYMODULE_claim_on_registration_node_update($node) {
if (is_object($node)) {
$type = $node->getType();
if ($type == 'your_conten_type') {
// GET New or logged in user id.
$uid = $node->getOwnerId();
// Get some other value of a custom field.
$field = $node->get('field_some_field')->value;
// Party!
// No need to call $node->save().
}
}
}
}