9 replies to this topic
#2
Posted 07 May 2012 - 02:20 AM
I think you can hook with a module the "___afterLoginRedirect" in the ProcessLogin.module. Haven't tried but it should be possible.
@somartist | modules created | support me, flattr my work flattr.com
#3
Posted 07 May 2012 - 02:56 AM
This is unknown territory for me...I assume you mean something like this?
...which didn't work for me.
public function init() {
$this->addHook('ProcessLogin::afterLoginRedirect', $this, 'helloTest');
}
public function helloTest (HookEvent $event) {
echo "Hello!";
}
...which didn't work for me.
#4
Posted 07 May 2012 - 06:49 AM
I went into the realms of logins and found it isn't possible like this. 
It's strange even if I change the core ProcessLogin module ___afterLoginRedirect to somthing else, it does nothing. Seems this like it is never used.
Though there a redirect in the module that does the redirect after login and appends an id if one found with get input. So after getting into the logic somehow, I found there's a ProcessHome.module that does only that: redirect to the /page/ when calling /processwire/ login. Though I still don't get it fully, nor do I understand why it is so complicated
Ryan?
So hooking the ProcessHome.module does work, though if you click the "Admin" breadcrumb it also redirects to the changed page.
It's strange even if I change the core ProcessLogin module ___afterLoginRedirect to somthing else, it does nothing. Seems this like it is never used.
Though there a redirect in the module that does the redirect after login and appends an id if one found with get input. So after getting into the logic somehow, I found there's a ProcessHome.module that does only that: redirect to the /page/ when calling /processwire/ login. Though I still don't get it fully, nor do I understand why it is so complicated
So hooking the ProcessHome.module does work, though if you click the "Admin" breadcrumb it also redirects to the changed page.
class LoginRedirect extends Wire implements Module {
public static function getModuleInfo() {
return array(
'title' => 'After Login Redirect',
'summary' => 'Redirect after login',
'version' => 100,
'autoload' => true,
'permission' => 'page-view'
);
}
public function init() {
$this->addHookBefore('ProcessHome::execute', $this, 'redirect');
}
public function redirect($event){
$event->replace = true; // replace hooked function completely
if($this->user->hasRole('editor')){
$this->session->redirect($this->pages->get(1186)->url);
} else {
$this->session->redirect("page/");
}
}
}
@somartist | modules created | support me, flattr my work flattr.com
#5
Posted 07 May 2012 - 10:02 AM
You can always create your own login page (and template) and have full control over the flow there. Logging in a user in PW is as simple as calling $session->login('name', 'pass'); If it authenticates, it returns a $user. If it doesn't, it returns null.
The $session->login might also be a good one to hook if you don't want to create your own login form. I think this would be preferable to trying to hook in ProcessLogin or ProcessHome.
The $session->login might also be a good one to hook if you don't want to create your own login form. I think this would be preferable to trying to hook in ProcessLogin or ProcessHome.
#9
Posted 07 May 2012 - 01:09 PM
Much appreciated here as well @evan. Definitely something I'll make use of.
Also tagged with one or more of these keywords: solved
Community Support →
Getting Started →
Why does $page->rootParent identify current section?Started by isellsoap, 27 Feb 2013 |
|
|
||
Community Support →
General Support →
Change default operator for ProcessPageSearch?Started by bcartier, 20 Dec 2012 |
|
|
||
Solved
Community Support →
General Support →
$image->size(); configuration questionsStarted by 97s, 02 Dec 2012 |
|
|
||
solved
Community Support →
Multi-Language Support →
Setting translated titleStarted by thomas.isberg, 30 Nov 2012 |
|
|
||
solved
Community Support →
Multi-Language Support →
Multi-Language support broken in dev-branchStarted by interrobang, 19 Nov 2012 |
|
|
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













