Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
We needed a way to modify the default $redirect_url
in certain situations. In our example, site admins need to be redirected to an admin-only URL upon auto-logout, whereas "regular" authenticated users will continue to the default $redirect_url
.
Proposed resolution
We propose adding a hook_autologout_redirect_url_alter
to allow the customisation of the $redirect_url
(and the $redirect_query
, if necessary).
A patch to add this functionality is attached -- can someone please review, thank you.
This is my first patch in Drupal, so please let me know if I did anything wrong.
Comments
Comment #2
44sunsets CreditAttribution: 44sunsets commentedComment #3
geoffreyr CreditAttribution: geoffreyr commented+1 for #2 - we've been using it for a while now and it works fine.
Comment #4
saurabh-chugh CreditAttribution: saurabh-chugh as a volunteer and at TATA Consultancy Services commentedI have tested and #2 is working fine. Thanks @44sunsets
Comment #5
DeaOm CreditAttribution: DeaOm at Agiledrop - Your Trusted Drupal Teammates commentedThis line of codedrupal_alter('autologout_redirect_url', $redirect_url, $redirect_query);
breaks the login altogether. I applied the patch, it appliesMy bad, did not notice this is for drupal 7. The patch applies.
Comment #6
DeaOm CreditAttribution: DeaOm at Agiledrop - Your Trusted Drupal Teammates commentedComment #7
bzoks CreditAttribution: bzoks at Agiledrop - Your Trusted Drupal Teammates commentedI applied patch at #2 and successfully tested provided hook. Marking as RTBC.
Comment #9
boshtian CreditAttribution: boshtian at Agiledrop - Your Trusted Drupal Teammates commented