By mixersoft on
I'm using Drake (Drupal/PHP) in this case, but my problem is still general.
I need to get my user from an outside jump page (showing their Flickr photos) to an internal drupal page. I need a valid $user->uid before I can import the Flickr photos into the user account. My problem is redirecting the user through Registration and/or Login before landing on the target page.
The following code successfully redirects the user through 'user/register' and then to the target $dest_url. But the redirect breaks if the user goes to the 'Login' tab. How do I fix that, or is there a better way to do this? Is there a page/module with both register and login on the SAME page?
function drake_authenticate($dest_url) {
// drupal_set_message("drake_dispatcher, dest=$dest_url");
// By default, all drake pages are visible,
// but redirect the following pages through user/register
$redirect_register_list = array('flickr/submit_order');
// grab the last 2 parts of the $dest_url
$target_parts = explode('/',$dest_url);
$target = array_pop($target_parts);
$target = array_pop($target_parts).'/'.$target;
$result = in_array($target, $redirect_register_list);
if (!$result) return;
// redirect to user/register
global $user;
if ($user->uid > 0) {
return;
} else {
drupal_set_message(t("Step 3 of 4. Please register or log in before importing your photos."));
unset($_REQUEST['destination']);
drupal_goto("user/register",drupal_get_destination());
}
print $output;
exit();
}
Comments
Check out the front page
Check out the front page module
Got Front Page installed, but I'm not sure it is what I want
I need a splash page only for unauthenticated users coming from specific URLs (facebook, flickr, etc.), they need to Register or Login, then go to a different destination page. I also need to pass session data through - my splash "page" is really the 3rd page of a shopping cart sequence.
Can you help me understand how to configure Front Page to do this? Will I be using php snippets to filter the referrer url, $_SERVER['HTTP_REFERRER'] (?).
Also, I want to redirect anonymous users to register/login and THEN to a destination URL. The specific problem is if the user lands on a Register page but then clicks to the Login page to log in -- I can't seem to keep the redirect destination in context when they change pages.