Entity Registration

by Gisle Hannemyr

The Entity registration module XXXX.

Table of contents

Drupal projects discussed in this chapter: Devel, Entity Registration.

Introduction

Entity Registration is for tracking registrations for anything people may sign up for.

A quick outline of how it works:

There are additional settings, but that is the basic outline: just create a registration type or two, give your entity a registration field, and point it at one of your registration types. For more detailed instructions, check out the README.

Registration types are like content types, but using the registration entity instead of node.

Configuration

Install the Registration project and enable Registration and Registration Views.

  1. Navigate to Administration → Structure → Registration → Registration types → Add registration type. Create at least one registration type bundle.
  2. Two fields are always present: Email and Registrant. You can add additional fields.
  3. It is now possible to add a registration field to any entity you want to enable registrations for.
  4. To decide how the opportunity to register shall appear in the entity, visit Manage display for the field. The options are: Registration Link (link to the registration form — this is the default), Registration Form (embed the actual form in entity display) Registration Type (display type, but registration disabled) and Hidden.
  5. To configure the registration settings for the entity with a registration field, click on the Manage fields tab, and then on edit in the "Operations" column.

Registrations are now enabled for the entity.

When a user is registered for an event, the link or the form will not appear on an entity unless the setting "Allow multiple registrations" is ticked in the entity's registration settinngs (see step #5).

Correct: SELECT registration.registration_id AS registration_id, node_registration.title AS node_registration_title, node_registration.nid AS node_registration_nid FROM {registration} registration LEFT JOIN {users} users_registration ON registration.user_uid = users_registration.uid LEFT JOIN {node} node_registration ON registration.entity_id = node_registration.nid AND registration.entity_type = 'node' WHERE ((( (users_registration.uid = '1') ))) LIMIT 10 OFFSET 0 SELECT node_registration.title AS node_registration_title, node_registration.nid AS node_registration_nid, registration.registration_id AS registration_id FROM {registration} registration LEFT JOIN {users} users_registration ON registration.user_uid = users_registration.uid LEFT JOIN {node} node_registration ON registration.entity_id = node_registration.nid AND registration.entity_type = 'node' WHERE (( (users_registration.status <> '0') )) LIMIT 10 OFFSET 0

Creating dummy content

If your site already has content, you may skip this step and work with that content instead.

If you're testing this on a newly created test site, you can generate dummy content as follows:

Install the Devel project. Enable the Devel generate module. Create a test user (name it "test"). Navigate to Administration → Configuration → Development → Generate Content and generate 50 nodes of type Article. They will be randomly assigned to existing users.

Using a contextual filter

[TBA]

Using a relationship

Navigate to Administration → Structure → Views → Add new view. Name it "Own content". Change the display format to be a HTML list of fields. Just leave everyting else set to the defaults.

views_res01.png.

Click Continue & edit.

Add a relationship. Expand the third column ("Advanced") and next to "Relationships", click Add. Locate the "Content: author" relationship and select it by ticking the box.

views_res02.png.

Click Apply (all displays) twice (i.e. use the default configuration).

Locate the "Filter Criteria" area in the first colum side and click Add. Locate the "User: current" relationship and select it by ticking the box."

views_res03.png.

Click Apply (all displays).

On the next screen, select "Yes" to configure the filter criterion to only show the current user.

views_res04.png.

Click Save (top right) to save the view. It should look like the image below.

views_res05.png.

Now, when a user visits the path /own-content, she or he should see her/his own content.

If you enable showing the SQL (it can be toggled by navigating to Administration → Structure → Views and visiting the Settings tab), the SQL should look like this, where x is the uid of the currently logged in user:

SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
FROM 
{node} node
LEFT JOIN {users} users_node ON node.uid = users_node.uid
WHERE (( (node.status = '1') AND( (users_node.uid = 'x') )))
ORDER BY node_created DESC
LIMIT 10 OFFSET 0

Final word

[TBA]


Last update: 2016-04-09 [gh].