Login Redirect

shawn.palmer's picture

Needs some help being pointed in the right direction.

I am working on a Continuing Education ( CE ) hours manager for a non-profit Assocation, the issue I am coming up with is when a member completes a local workshop we are planing on handing them a business card with a QR code ( URL encoded: http://URL/workshop/WORKSHOP_ID/UNIQUE_ID ) as well as the workshop_ID and the Unique_ID and the name of the workshop for manual entry

what I need or more pointed in the right direction for is when they follow the QR ( most likely with a phone or other handled ) they will not already be login so I need the page to redirect them to a log-in page once login go to the confirmation page for the work they just completed or to a testing page

this is being developed on Drupal6 as pure custom modules due to performance reasons

Shawn

Comments

Thanks

shawn.palmer's picture

No I hadn't really looked at in the modules page for an existing module. but at least I should be able to use it as reference to build what I need

Again Thanks
Shawn

Destination parameter

mradcliffe's picture

You can also pass in the destination parameter in the URL, which user/login supports.

http://my.site/user/login?destination=some/path/to/a/page

On second thought, login destination is the way to go anyway because in your case you could already be logged in.

I will look into the

shawn.palmer's picture

I will look into the ?destination args as well.

Thanks
Shawn

Drupal_goto

dougvann's picture

Shawn,
If you're going to write your own module to handle redirects you will probably end up using
drupal_goto()
see http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_go...

I rather imagine this will be a module that uses hook_init to get triggered on every page load. Here's some pseudo code for you that assumes your module name is "shawn."

shawn_init() {
global $user;
if ($user->uid ==0) drupal_goto(the loggin page);
return;
}

In this example NO anonymous user can ever land on any page except the log in page. Or more acurtaely any page the anonymous user goes to will immediately redirect them to the loggin page.
If that is what you want then the above code get's u almost there.
;-)

  • Doug Vann [Drupal Trainer, Consultant, Developer]
  • Synaptic Blue Inc. [President]
  • http://dougvann.com

Doug, here is what I think I

shawn.palmer's picture

Doug,

here is what I think I am going to end up with

_init() {
global $user;
if ($user->uid ==0) drupal_goto("user/login" , "destination=workshops/$workshopID/$MyID" );
return;
}

see any reason why that wouldn't work or is it going to do what I expect it to?

Looks good

dougvann's picture

So long as $MyID is assigned somewhere.
Let me know how that goes.

  • Doug Vann [Drupal Trainer, Consultant, Developer]
  • Synaptic Blue Inc. [President]
  • http://dougvann.com

Thanks for your Help

shawn.palmer's picture

Doug,

Just wanted to say thanks, its going to be a while before I can be sure that it works the way that I need it to as I still need to write 3 forms and a hand full custom interactions to get it all working

so, Thank you very much.

Shawn