From 96f987e1c6b21cf1cfe61f5aae05f67bc16c3cca Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Wed, 4 Jan 2023 11:31:05 -0500 Subject: [PATCH] avoid empty error message when submitting PCP page. --- CRM/PCP/Page/PCPInfo.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/CRM/PCP/Page/PCPInfo.php b/CRM/PCP/Page/PCPInfo.php index 2a3cf3762e..53711f255e 100644 --- a/CRM/PCP/Page/PCPInfo.php +++ b/CRM/PCP/Page/PCPInfo.php @@ -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 click here 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 click here 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, -- 2.25.1