You are viewing the PKP Support Forum | PKP Home Wiki

login hook?

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

login hook?

Postby christo » Thu Sep 06, 2007 2:54 am


I have looked through the lists of available hooks, and im sure im just missing it; but what is the hook to register against the post successful login event.

I want to intercept a successful login attempt and forward the user to a specific page if one is specified.

Posts: 22
Joined: Mon Jan 09, 2006 12:04 am
Location: Grahamstown, South Africa

Re: login hook?

Postby asmecher » Thu Sep 06, 2007 8:50 am

Hi Christo,

There's no specific hook for that, but you can use Request::redirect hook to intercept the usual redirect on a successful login. You can check that Request::getRequestedOp == 'signIn' and $url in the hook call == Request::url(null, 'user'). If so, redirect to your own page (though you may have to do some nimble work with a static variable to make sure you don't end up recursively calling the hook through repeated calls to Request::redirect).

Alec Smecher
Public Knowledge Project Team
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Re: login hook?

Postby christo » Tue Sep 11, 2007 7:55 am

Silly me! I didnt notice this:
Code: Select all
        $source = Request::getUserVar('source');
   if (isset($source) && !empty($source)) {
      Request::redirectUrl(Request::getProtocol() . '://' . Request::getServerHost() . $source, false);

just adding ?source=/path/to/redirect/to to the url does the trick.

If anyone is interested; i used this code to add the correct redirect parameters to my login redirect:

Code: Select all
//first get the absolute url using the Request Object's url function:
$url = Request::url('journal','page','op','path');
//then i strip off all the stuff that the stuff from the front (this is later added back on by the redirector)
$url = ereg_replace(Request::getProtocol() . '://' . Request::getServerHost(),"",$url);
if (!Validation::isLoggedIn()) {   
        //and now we redirect them to the loging page with our ?source=$url appended to the querystring
   Request::redirect('user','login',null,null,array("source" => $url));

..hope that helps someone...
Posts: 22
Joined: Mon Jan 09, 2006 12:04 am
Location: Grahamstown, South Africa

Return to OJS Development

Who is online

Users browsing this forum: No registered users and 1 guest