avoid empty error message when submitting PCP page.
authorJamie McClelland <jm@mayfirst.org>
Wed, 4 Jan 2023 16:31:05 +0000 (11:31 -0500)
committerJamie McClelland <jm@mayfirst.org>
Wed, 4 Jan 2023 16:31:05 +0000 (11:31 -0500)
CRM/PCP/Page/PCPInfo.php

index 2a3cf3762ee9719f58031f0bc305cefe07268639..53711f255e04dd2be0b08f5e70a92957c2632953 100644 (file)
@@ -62,17 +62,6 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page {
     $pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
     $approvedId = CRM_Core_PseudoConstant::getKey('CRM_PCP_BAO_PCP', 'status_id', 'Approved');
 
-    // check if PCP is created by anonymous user
-    $anonymousPCP = CRM_Utils_Request::retrieve('ap', 'Boolean', $this);
-    if ($anonymousPCP) {
-      $loginURL = $config->userSystem->getLoginURL();
-      $anonMessage = ts('Once you\'ve received your new account welcome email, you can <a href=%1>click here</a> to login and promote your campaign page.', [1 => $loginURL]);
-      CRM_Core_Session::setStatus($anonMessage, ts('Success'), 'success');
-    }
-    else {
-      $statusMessage = ts('The personal campaign page you requested is currently unavailable. However you can still support the campaign by making a contribution here.');
-    }
-
     $pcpBlock = new CRM_PCP_DAO_PCPBlock();
     $pcpBlock->entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($pcpInfo['page_type']);
     $pcpBlock->entity_id = $pcpInfo['page_id'];
@@ -86,6 +75,21 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page {
       $urlBase = 'civicrm/event/register';
     }
 
+    // check if PCP is created by anonymous user
+    $anonymousPCP = CRM_Utils_Request::retrieve('ap', 'Boolean', $this);
+    if ($anonymousPCP) {
+      $loginURL = $config->userSystem->getLoginURL();
+      $anonMessage = ts('Once you\'ve received your new account welcome email, you can <a href=%1>click here</a> to login and promote your campaign page.', [1 => $loginURL]);
+      CRM_Core_Session::setStatus($anonMessage, ts('Success'), 'success');
+      CRM_Utils_System::redirect(CRM_Utils_System::url($urlBase,
+          "reset=1&id=" . $pcpInfo['page_id'],
+          FALSE, NULL, FALSE, TRUE
+      ));
+    }
+    else {
+      $statusMessage = ts('The personal campaign page you requested is currently unavailable. However you can still support the campaign by making a contribution here.');
+    }
+
     if ($pcpInfo['status_id'] != $approvedId || !$pcpInfo['is_active']) {
       if ($pcpInfo['contact_id'] != $session->get('userID') && !$permissionCheck) {
         CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url($urlBase,