Provide an administration interface for a user to manage his own registrations for an entity.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dpi’s picture

Attached patch adds an additional sub-tab to `Register`: listing logged-in users' registrations.

dpi’s picture

Extra functionality: Add a message to registration_form reminding user if he has already registered for this entity.

dpi’s picture

Status: Active » Needs review

Change status^^

dpi’s picture

Rerolled against alpha4

levelos’s picture

Status: Needs review » Needs work

Thanks @dpi. I think we should place the list of a user's registrations on their account page, similar to how Signup, Commerce, and others do. I'm also not sure of the need for the message on the registration form. Seems that depending on permissions and settings, we should show either the form or the message, not both. Related to #1308894: Add setting: Maximum registrations per user..

Also just want to note that it'd be easy to add a list of a user's registrations with a View, whether or not this is in the core module.

dpi’s picture

If the idea behind Registration is to allow users to make multiple registrations per entity, doesn't it make sense to allow the user to see them with a built in table? e.g If a user has tens of registrations for an entity, which method is going to make sense:

I think we should place the list of a user's registrations on their account page

I'm not advocating a global list of registrations per user. Rather users registrations per entity. Are we misunderstanding eachother?

Or do you think a global list makes more sense? in which case a user built view would make more sense than inclusion with Registration

And yes, depending on settings (eg: multiple registrations per user per entity == 1), this functionality should be disabled.

attiks’s picture

It's kind of working for me:

  • I see the the link 'You have 2 existing registrations.' but the email field is still pre-filled with my own email, this isn't going to work because it's already stored in the database
  • On the node/xxx/register/list there's a column for id, i think it's better to hide it, it will confuse site users
  • On the node/xxx/register/list there's also a delete button which shouldn't show (see #1472250: View and edit own registration permissions)
  • On the node/xxx/register/list count is also showing although people can only register for 1 slot.

I think slot is used in two ways in this discussion:

  1. If one person register and wants to indicate that he will come with multiple persons he can use the slot field for this
  2. If on the other hand the site owner wants full details of each user, slot has to be 1 and the site user needs an easy way to add multiple people

I think we better expose the registration info to views so site builders can add the list where ever they want: separate page, account, node/xxx/register, ...

levelos’s picture

@dpi,

Or do you think a global list makes more sense? in which case a user built view would make more sense than inclusion with Registration

I did think a global list made sense, perhaps grouped by event. I could be disuaded from that approach, but seems fairly standard. Yes, it could be done with Views, but I was hoping to provide all essential functionality w/o that.

dave bruns’s picture

Component: Code » Registration Core

Just checking to confirm: At the moment (alpha5), it's not possible for normal authenticated users to see and/or manage registrations (including their own). Is that right?

I ask because I see that we can grant users a number of Registration permissions:

  • View all registrations
  • View own registrations
  • Edit own registrations
  • Delete own registrations

But in my (limited) testing logged in as a user with a role that has these permissions, I haven't seen any controls to allow a normal users to do these things.

dpi’s picture

That is correct. As a user you cannot see a list of registrations for a host entity. Use views and optionally eva.

A user still has those rights if he has the direct link to the registration entity.

jossensei’s picture

I've tried something to get an "Edit my registration" link instead of the "Register" link if a user is already registered :

- in registration_menu(), in the entity local tasks foreach loop, I've added :

      $items[$type . '/%entity_object/registration'] = array(
        'load arguments' => array($type),
        'title' => 'Edit my registration',
        'page callback' => 'registration_registration_page',
        'page arguments' => array(0, 1),
        'access callback' => 'registration_registration_page_access',
        'access arguments' => array(0, 1),
        'type' => MENU_LOCAL_TASK,
      );

- and then I've added these two funcitions :

function registration_registration_page_access($entity_type, $entity) {
  $account = $GLOBALS['user'];
  list($entity_id) = entity_extract_ids($entity_type, $entity);

  if ($account->uid && $type = registration_get_entity_registration_type($entity_type, $entity)) {
    $registration = entity_get_controller('registration')->create(array(
      'entity_type' => $entity_type,
      'entity_id' => $entity_id,
      'type' => $type,
    ));
    $is_registered = registration_is_registered($registration, NULL, $account->uid);
    if($is_registered && user_access("update own $type registration")) {
      return TRUE;
    }
  }
  return FALSE;
}

And

function registration_registration_page($entity_type, $entity) {
  $account = $GLOBALS['user'];
  list($entity_id) = entity_extract_ids($entity_type, $entity);
  if ($account->uid && $type = registration_get_entity_registration_type($entity_type, $entity)) {
    $registration = entity_get_controller('registration')->create(array(
      'entity_type' => $entity_type,
      'entity_id' => $entity_id,
      'type' => $type,
    ));
    $result = db_select('registration', 'r')
      ->fields('r')
      ->condition('entity_id', $registration->entity_id, '=')
      ->condition('entity_type', $registration->entity_type, '=')
      ->condition('user_uid', $account->uid, '=')
      ->execute()
      ->fetchAssoc();
    if($result){
      $user_registration = entity_load_single('registration', $result['registration_id']);
      $registration_edit_form = drupal_get_form('registration_form',$user_registration);
      return drupal_render($registration_edit_form);
    }
  }  
  return false;
}
Mile23’s picture

Patch in #4 doesn't apply cleanly against 7.x-1.x

Mile23’s picture

I made a sandbox project that leverages hook_registration_access() to allow the user to view registrations they're enrolled in, even if they didn't create it.

http://drupal.org/sandbox/Mile23/1975698

bumblebee123’s picture

Hi Everyone,

Is this feature gonna be introduced in the core module sometime?

Thanks,
Judit

ryanfc78’s picture

Issue summary: View changes

I have the Registration Form built into the event (not the link), but can't seem to find a way for the user to then edit their reservations. I have created a View with a Menu: Tab. If the admin logs in clicks on the Tab it shows the reservation they made. But if a member logs in and clicks the Tab it shows that they have no reservations. I know they do as I logged in as that user and registered. When I am logged in as an admin I see the members RSVP.

Has anyone found a way to let the user edit their reservation? I really need them to be able to edit their reservation in case they can no longer come or decide to bring a guest. Looked through the issues, but doesn't seem like anyone has found a solution. I am using 7.x-1.3

roball’s picture

Below is the view_code of the View I am using to add a "Registrations" tab to each authenticated user's profile page.

$view = new view();
$view->name = 'registrations_per_user';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'registration';
$view->human_name = 'Registrations per User';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'My Registrations';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'role';
$handler->display->display_options['access']['role'] = array(
  2 => '2',
);
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '50';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'registration_id' => 'registration_id',
  'title' => 'title',
  'created' => 'created',
  'updated' => 'updated',
  'name' => 'name',
  'name_1' => 'name_1',
  'anon_mail' => 'anon_mail',
  'mail' => 'mail',
  'count' => 'count',
  'state' => 'state',
  'edit_registration' => 'edit_registration',
  'delete_registration' => 'edit_registration',
);
$handler->display->display_options['style_options']['default'] = 'registration_id';
$handler->display->display_options['style_options']['info'] = array(
  'registration_id' => array(
    'sortable' => 1,
    'default_sort_order' => 'desc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'title' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'created' => array(
    'sortable' => 1,
    'default_sort_order' => 'desc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'updated' => array(
    'sortable' => 1,
    'default_sort_order' => 'desc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'name' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'name_1' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'anon_mail' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'mail' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'count' => array(
    'sortable' => 1,
    'default_sort_order' => 'desc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'state' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'edit_registration' => array(
    'align' => '',
    'separator' => ' | ',
    'empty_column' => 0,
  ),
  'delete_registration' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* Header: Global: Text area */
$handler->display->display_options['header']['area']['id'] = 'area';
$handler->display->display_options['header']['area']['table'] = 'views';
$handler->display->display_options['header']['area']['field'] = 'area';
$handler->display->display_options['header']['area']['content'] = 'List of registrations submitted by <em>[name]</em>.';
$handler->display->display_options['header']['area']['format'] = 'filtered_html';
$handler->display->display_options['header']['area']['tokenize'] = TRUE;
/* No results behavior: Global: Unfiltered text */
$handler->display->display_options['empty']['area_text_custom']['id'] = 'area_text_custom';
$handler->display->display_options['empty']['area_text_custom']['table'] = 'views';
$handler->display->display_options['empty']['area_text_custom']['field'] = 'area_text_custom';
$handler->display->display_options['empty']['area_text_custom']['label'] = 'Empty text';
$handler->display->display_options['empty']['area_text_custom']['empty'] = TRUE;
$handler->display->display_options['empty']['area_text_custom']['content'] = 'You have not yet registered for any event.';
/* Relationship: Registration: Author entity author_uid */
$handler->display->display_options['relationships']['author']['id'] = 'author';
$handler->display->display_options['relationships']['author']['table'] = 'registration';
$handler->display->display_options['relationships']['author']['field'] = 'author';
$handler->display->display_options['relationships']['author']['label'] = 'Created By';
/* Relationship: Registration: User */
$handler->display->display_options['relationships']['user_uid']['id'] = 'user_uid';
$handler->display->display_options['relationships']['user_uid']['table'] = 'registration';
$handler->display->display_options['relationships']['user_uid']['field'] = 'user_uid';
/* Relationship: Registration: Registration to Node */
$handler->display->display_options['relationships']['registration_related_node']['id'] = 'registration_related_node';
$handler->display->display_options['relationships']['registration_related_node']['table'] = 'registration';
$handler->display->display_options['relationships']['registration_related_node']['field'] = 'registration_related_node';
$handler->display->display_options['relationships']['registration_related_node']['label'] = 'Registration node';
/* Field: Registration: Registration ID */
$handler->display->display_options['fields']['registration_id']['id'] = 'registration_id';
$handler->display->display_options['fields']['registration_id']['table'] = 'registration';
$handler->display->display_options['fields']['registration_id']['field'] = 'registration_id';
$handler->display->display_options['fields']['registration_id']['label'] = 'ID';
$handler->display->display_options['fields']['registration_id']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['registration_id']['alter']['path'] = 'registration/[registration_id]';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['relationship'] = 'registration_related_node';
$handler->display->display_options['fields']['title']['label'] = 'Event';
/* Field: Registration: Date created */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'registration';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['label'] = 'Created';
$handler->display->display_options['fields']['created']['date_format'] = 'short';
$handler->display->display_options['fields']['created']['second_date_format'] = 'long';
/* Field: Registration: Date updated */
$handler->display->display_options['fields']['updated']['id'] = 'updated';
$handler->display->display_options['fields']['updated']['table'] = 'registration';
$handler->display->display_options['fields']['updated']['field'] = 'updated';
$handler->display->display_options['fields']['updated']['label'] = 'Updated';
$handler->display->display_options['fields']['updated']['date_format'] = 'short';
$handler->display->display_options['fields']['updated']['second_date_format'] = 'long';
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'author';
$handler->display->display_options['fields']['name']['label'] = 'Created By';
$handler->display->display_options['fields']['name']['exclude'] = TRUE;
/* Field: User: Name */
$handler->display->display_options['fields']['name_1']['id'] = 'name_1';
$handler->display->display_options['fields']['name_1']['table'] = 'users';
$handler->display->display_options['fields']['name_1']['field'] = 'name';
$handler->display->display_options['fields']['name_1']['relationship'] = 'user_uid';
$handler->display->display_options['fields']['name_1']['label'] = 'User';
$handler->display->display_options['fields']['name_1']['exclude'] = TRUE;
/* Field: Registration: Anonymous e-mail */
$handler->display->display_options['fields']['anon_mail']['id'] = 'anon_mail';
$handler->display->display_options['fields']['anon_mail']['table'] = 'registration';
$handler->display->display_options['fields']['anon_mail']['field'] = 'anon_mail';
$handler->display->display_options['fields']['anon_mail']['label'] = '';
$handler->display->display_options['fields']['anon_mail']['exclude'] = TRUE;
$handler->display->display_options['fields']['anon_mail']['element_label_colon'] = FALSE;
/* Field: User: E-mail */
$handler->display->display_options['fields']['mail']['id'] = 'mail';
$handler->display->display_options['fields']['mail']['table'] = 'users';
$handler->display->display_options['fields']['mail']['field'] = 'mail';
$handler->display->display_options['fields']['mail']['relationship'] = 'user_uid';
$handler->display->display_options['fields']['mail']['label'] = 'Email';
$handler->display->display_options['fields']['mail']['exclude'] = TRUE;
$handler->display->display_options['fields']['mail']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['mail']['alter']['text'] = '[anon_mail][mail]';
$handler->display->display_options['fields']['mail']['hide_alter_empty'] = FALSE;
/* Field: Registration: Slots consumed */
$handler->display->display_options['fields']['count']['id'] = 'count';
$handler->display->display_options['fields']['count']['table'] = 'registration';
$handler->display->display_options['fields']['count']['field'] = 'count';
$handler->display->display_options['fields']['count']['label'] = 'Count';
$handler->display->display_options['fields']['count']['exclude'] = TRUE;
/* Field: Registration: State entity */
$handler->display->display_options['fields']['state']['id'] = 'state';
$handler->display->display_options['fields']['state']['table'] = 'registration';
$handler->display->display_options['fields']['state']['field'] = 'state';
$handler->display->display_options['fields']['state']['label'] = 'State';
/* Field: Registration: Edit link */
$handler->display->display_options['fields']['edit_registration']['id'] = 'edit_registration';
$handler->display->display_options['fields']['edit_registration']['table'] = 'registration';
$handler->display->display_options['fields']['edit_registration']['field'] = 'edit_registration';
$handler->display->display_options['fields']['edit_registration']['label'] = 'Actions';
/* Field: Registration: Delete link */
$handler->display->display_options['fields']['delete_registration']['id'] = 'delete_registration';
$handler->display->display_options['fields']['delete_registration']['table'] = 'registration';
$handler->display->display_options['fields']['delete_registration']['field'] = 'delete_registration';
/* Contextual filter: Registration: Author entity author_uid */
$handler->display->display_options['arguments']['author']['id'] = 'author';
$handler->display->display_options['arguments']['author']['table'] = 'registration';
$handler->display->display_options['arguments']['author']['field'] = 'author';
$handler->display->display_options['arguments']['author']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['author']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['author']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['author']['summary_options']['items_per_page'] = '25';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['path'] = 'user/%/registrations';
$handler->display->display_options['menu']['type'] = 'tab';
$handler->display->display_options['menu']['title'] = 'Registrations';
$handler->display->display_options['menu']['weight'] = '0';
$handler->display->display_options['menu']['context'] = 0;
$handler->display->display_options['menu']['context_only_inline'] = 0;
$handler->display->display_options['tab_options']['title'] = 'Manage Registrations';
$handler->display->display_options['tab_options']['weight'] = '0';
$translatables['registrations_per_user'] = array(
  t('Master'),
  t('My Registrations'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('« first'),
  t('‹ previous'),
  t('next ›'),
  t('last »'),
  t('List of registrations submitted by <em>[name]</em>.'),
  t('Empty text'),
  t('You have not yet registered for any event.'),
  t('Created By'),
  t('User'),
  t('Registration node'),
  t('ID'),
  t('.'),
  t(','),
  t('Event'),
  t('Created'),
  t('Updated'),
  t('Email'),
  t('[anon_mail][mail]'),
  t('Count'),
  t('State'),
  t('Actions'),
  t('Delete link'),
  t('All'),
  t('Page'),
);
keneso’s picture

@roball #16

Thank you very much.

It did it for me.

Kojo Unsui’s picture

Thanks for sharing @roball. #16 views made me earn some time ;-)

tsaks’s picture

@roball #16

Thank you! That saved me countless hours!

tschewe’s picture

I'd love to implement #16 but don't know how. Can some patient soul point me in the right direction?

hockey2112’s picture

@tschewe, follow these steps:

  1. go to /admin/structure/views/import
  2. copy the code from #16, paste it on that page
  3. click the Import button
  4. modify the view as you see fit, save
  5. that's it!
markusd1984’s picture

thanks @roball for sharing, #16 worked a treat.

I replaced the delete with a cancel button / link that will keep a track record instead of deleting it entirely.

john.oltman’s picture

Status: Needs work » Closed (outdated)