Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#2436 On WordPress, redirect back to the event registration o… #19718

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -926,20 +926,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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be forced to the front end or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH this was copied from https://github.com/civicrm/civicrm-core/blob/master/CRM/Utils/System/DrupalBase.php#L488-L505
It works as is for the case described in https://lab.civicrm.org/dev/core/-/issues/2436
I'll remove the other bits and keep it simple. If anyone wants this for PCP's they can add later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drupal doesn't have the same concern about front end v backend as WordPress thoughts @kcristiano @haystack

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do an r-run I am concerned about who it will get the URLs depending on front-end vs back-end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't envisage a situation where this redirect would happen on the back end. If someone can give an example, then yes I'd agree that forcing front end would be necessary.

}
return $destination;
}

/**
Expand Down