Skip to content

Commit

Permalink
Merge pull request #19718 from aydun/wp-login-redirect
Browse files Browse the repository at this point in the history
dev/core#2436 On WordPress, redirect back to the event registration o…
  • Loading branch information
eileenmcnaughton authored Apr 9, 2021
2 parents 9e210e4 + 7cecea8 commit c2655a0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CRM/Utils/System/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 28 additions & 6 deletions CRM/Utils/System/WordPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit c2655a0

Please sign in to comment.