Menu

#447 Contact Information for Event Registrants/ Participants

open
nobody
1
2022-02-27
2022-02-27
carmean
No

We needed simple contact information from Event Registrants (or Participants). I was able to do this by adding a column to the participants table and inserting or modifying the code below. Iit serves our purpose but has not been tested much. Hopefully this is useful and something with the same purpose can be incorporated into the code.

In mySQL, if you have already run the mysql to create the tables, you can add the column with this MySQL command:

ALTER TABLE mrbs_participants ADD COLUMN user_contact_info varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL;

config.inc.php

// Vocab overrides
//Used for registrants additional information in view_entry.php
$vocab["participants_contact_info"] =  "Principal Investigator and Lab Room #";
$vocab["participants_contact_brief"] =  "PI & Lab";

File: registration_handler.php

// Register a user for an event
// 2022 added field user_contact_info   line 48/139
//function register($username, $event_id)
function register($username, $user_contact_info, $event_id)
   // then register the user
        $sql = "INSERT INTO " . _tbl('participants') . " (entry_id, username, user_contact_info, create_by, registered)
                     VALUES (:entry_id, :username, :user_contact_info, :create_by, :registered)";

        $sql_params = array(
          ':entry_id'   => $event_id,
          ':username'   => $username,
          ':user_contact_info'  => $user_contact_info,
          ':create_by'  => $mrbs_username,
          ':registered' => time()
        );
//  2022  added this line  (line 127/139)
    $user_contact_info = get_form_var('user_contact_info', 'string');
// 2022 added $user_contact_info,
    register($username, $user_contact_info, $event_id);
//    register($username, $event_id);

File: view_entry.php

    $display_name = (isset($registrant_user)) ? $registrant_user->display_name : $registrant['username'];
    $display_info = (isset($user_contact_info)) ? $user_contact_infor->display_info : $registrant['user_contact_info'];  // 2022 (line 53/1041)
    $sortname = get_sortable_name($display_name);
    echo '<td data-order="' . htmlspecialchars($sortname) . '">' . htmlspecialchars($display_name) . ' (' . htmlspecialchars($display_info) . ')</td>';
  if (!$can_register_others)
  {
    $form->addHiddenInput('username', $mrbs_user->username);
// 2022     line 185/1041
    $fieldset = new ElementFieldset();
    $params = array(
        'value'     => '',
        'disabled'  =>  false,
        'required'  =>  true,
        'field'     => 'participants.user_contact_info',
        'label'     =>  get_vocab('participants_contact_info'),
        'name'      => 'user_contact_info',
      );
    $fieldset->addElement(get_user_field($params, true));
    $form->addElement($fieldset);
  }
  else
  {
    $fieldset = new ElementFieldset();
    $params = array(
        'value'     => $mrbs_user->username,
        'disabled'  => false,
        'required'  => true,
        'field'     => 'participants.username',
        'label'     => get_vocab('name'),
        'name'      => 'username',
      );
    $fieldset->addElement(get_user_field($params, true));
    $form->addElement($fieldset);

// 2022     line 212 of 1041
    $fieldset = new ElementFieldset();
    $params = array(
        'value'     => '',
        'disabled'  =>  false,
        'required'  =>  false,
        'field'     => 'participants.user_contact_info',
        'label'     =>  get_vocab('participants_contact_info'),
        'name'      => 'user_contact_info',
      );
    $fieldset->addElement(get_user_field($params, true));
    $form->addElement($fieldset);
    if (!$can_see_others)
    {
    $display_info = (isset($user_contact_info)) ? $user_contact_infor->display_info : $registrant['user_contact_info'];  //  2022 (line 318/1041)
    echo "\n<p><br>" . get_vocab('participants_contact_brief') . ": <b>" . (htmlspecialchars($display_info)) . "</b></p>\n";

      generate_cancel_registration_button(

Discussion

MongoDB Logo MongoDB