diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 6a1ce83351b0..fd5ff6432e76 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -436,7 +436,7 @@ public function isFrontEndPage() { * Get user login URL for hosting CMS (method declared in each CMS system class) * * @param string $destination - * If present, add destination to querystring (works for Drupal only). + * If present, add destination to querystring (works for Drupal and WordPress only). * * @return string * loginURL for the current CMS diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 52070fa22c26..5d173234b2f5 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -932,20 +932,42 @@ public function getUniqueIdentifierFromUserObject($user) { * @inheritDoc */ public function getLoginURL($destination = '') { - $config = CRM_Core_Config::singleton(); - $loginURL = wp_login_url(); - return $loginURL; + return wp_login_url($destination); } /** - * FIXME: Do something. - * * @param \CRM_Core_Form $form * * @return NULL|string */ public function getLoginDestination(&$form) { - return NULL; + $args = NULL; + + $id = $form->get('id'); + if ($id) { + $args .= "&id=$id"; + } + else { + $gid = $form->get('gid'); + if ($gid) { + $args .= "&gid=$gid"; + } + else { + // Setup Personal Campaign Page link uses pageId + $pageId = $form->get('pageId'); + if ($pageId) { + $component = $form->get('component'); + $args .= "&pageId=$pageId&component=$component&action=add"; + } + } + } + + $destination = NULL; + if ($args) { + // append destination so user is returned to form they came from after login + $destination = CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1' . $args); + } + return $destination; } /**