Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-17058

Create CMS User on Event Registration breaks in some conditions

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.6
    • Fix Version/s: Unscheduled
    • Component/s: CiviEvent
    • Labels:
      None
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      When registering online for an event, using a profile that creates a CMS account, the process fails under the following conditions:

      • the user has selected "pay later"
      • the profile contains an email field that is not "Primary" but some other location (Home, Work, etc).

      In the Drupal 7 case, at minimum, the CMS reports back "E-mail address field is required" and fails to create the user account. Additionally, no email confirmations are sent from CiviCRM, and the user is directed to the homepage rather than the Thank You page.

      I have isolated the issue to this code in CRM/Event/Form/Registration.php:

          // create CMS user
          if (!empty($this->_params['cms_create_account'])) {
            $this->_params['contactID'] = $contactID;
      
            if (array_key_exists('email-5', $this->_params)) {
              $mail = 'email-5';
            }
            else {
              foreach ($this->_params as $name => $dontCare) {
                if (substr($name, 0, 5) == 'email') {
                  $mail = $name;
                  break;
                }
              }
            }
      
            // we should use primary email for
            // 1. free event registration.
            // 2. pay later participant.
            // 3. waiting list participant.
            // 4. require approval participant.
            if (!empty($this->_params['is_pay_later']) ||
              $this->_allowWaitlist || $this->_requireApproval || empty($this->_values['event']['is_monetary'])
            ) {
              $mail = 'email-Primary';
            }
      
            if (!CRM_Core_BAO_CMSUser::create($this->_params, $mail)) {
              CRM_Core_Error::statusBounce(ts('Your profile is not saved and Account is not created.'));
            }
      

      The email-Primary may not exist in the profile, so that final if-statement is a problem. One fix could be to amend the if statement:

            if ((!empty($this->_params['is_pay_later']) ||
              $this->_allowWaitlist || $this->_requireApproval || empty($this->_values['event']['is_monetary'])) && array_key_exists('email-Primary', $this->_params)
            ) {
              $mail = 'email-Primary';
            }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jake.mw Jake Martin White
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: