-1

I have a destination parameter appended to /user/login using Redirect 403 to User Login. This presents users with the login page when they encounter a 403, allowing them to login and subsequently be redirected back to the page they were just on. For whatever reason, the redirect functionality that's built in is not working -- users are still directed to /user after logging in.

Within my form_alter, I have tried:

  • Using $form['#submit'][] to set $form_state['#redirect'], which is ignored.
  • Similar in $form['submit']['#submit'][], along with unset($form['#action']) which I'm not familiar with but I read somewhere might be applicable.
  • Using drupal_register_shutdown_function('drupal_goto', $destination) to set the redirect as a shutdown function which should execute after everything else and force a redirect.
  • Setting drupal_static_reset('drupal_get_destination') before my shutdown function to try and reset any other redirects.

In all cases I have verified that my callbacks are running and that variables are being set as they should be, but nothing is working. Any ideas how to force this redirect or debug what is overriding it?

0

With the Redirect 403 to User Login module, you shouldn't have to add any hooks for the behavior to kick-in. You just need to enable the module and check its settings at admin/config/system/site-information

Here are some debugging suggestions:

  1. Check for conflicting modules that serve similar functionality being enabled

    • Redirect 403 to User Login
    • Login Toboggan
  2. Disable custom modules and custom theme, and test redirect behavior. It should work out of the box. If not, try reinstalling the module.

  3. Then, turn the custom theme and each custom module on one-by-one to identify which is causing the conflict. Once you've identified if it's in the theme or a custom module, search the hooks for any redirect behaviors.
  • Yup -- the "Login Destination" module was the culprit. Who would have thought?! Ha. It implements hook_drupal_goto_alter which was overriding everything I threw at it, so I had to implement my own version of the hook to override that. – Mrweiner Jan 12 '18 at 23:12
0

Just to clarify what I did to fix this for anybody who might land on this in the future, the Login Destination module implements hook_drupal_goto_alter, which appears to override all other redirects. In order to override it, I had to implement my own version of hook_drupal_goto_alter, as well as make sure that my module weight was heavy enough to take precedence over Login Destination's implementation. To help set module weights, I used Modules Weight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.