: How do you get Drupal to go to a page other than the User Profile on login? ISSUE: I've tried a few things to get Drupal to STOP going to the User Prolfile page on login. I even installed
ISSUE: I've tried a few things to get Drupal to STOP going to the User Prolfile page on login. I even installed the LoginToboggan module, which has nice features, just doesn't stop Drupal from sending all users that login to their User Profile page. Just to be clear, LoginToboggan's "optionally redirect [of] the user to a specific page when using the 'immediate login' feature" -- is ONLY for new users, not existing users... Yes, I know, makes no sense.
GOAL: Just need to be able to set the login page; don't need to set the page load based on role, but hey, that would be nice if it's not crazy complex.
UPDATE: Figured out a fix based on my needs, see my answer below.
More posts by @Jamie184
4 Comments
Sorted by latest first Latest Oldest Best
Sure you can do this in Drupal using the Rules module ...
Here is an example of such rule for Drupal version 7, in what is called Rules "export format":
{ "rules_redirect_selected_roles_to_selected_term_pages" : {
"LABEL" : "Redirect selected roles to selected term pages",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "user_login" : [] },
"IF" : [
{ "user_has_role" : { "account" : [ "account" ], "roles" : { "value" : { "5" : "5" } } } }
],
"DO" : [ { "redirect" : { "url" : "node/123" } } ]
}
}
You should be able to just "import" the above rule in your own Drupal installation via Drupal's Admin UI, using the link labeled "import rule" which is located at relative path admin/config/workflow/rules/reaction/import in your own Drupal site.
Some more details about what the above rule actually does:
It is triggered by the Rules Event = User has logged in.
It includes a Rules Condition which in this case is User has role(s) = subscriber. Actually the 4 in the export format above corresponds to subscriber in the Drupal installation where I exported this from, if you would change, before importing, that 4 to a 3, it would correspond to administrator instead (just pick whatever "role" you'd want, by changing it using the Rules UI, after you imported this rule). If you'd want this to apply for any role, then just omit (delete) this Rules condition (the easiest way to perform such delete, is using the Rules UI after you imported this example).
It will perform a Rules Action = Page redirect = node/123. This node/123 is what is desired in the Drupal installation where I exported this from, but you can simply change that to any valid (relative) path that you want. So make sure to change that node/123 to the relative path of the page corresponding to your "... page other than the User Profile on login ...".
That's it, works like a charm!
You could make it even (way) more sophisticated by enhancing the rule with options like:
Redirect to a page (path) that depends of the role of the users.
Make the redirect depend on the day(s) of the week, or the time of the day (eg during open/close hours of a shop).
PS: if you're interested in (way) more examples of amazing things you can do with the Rules module, then visit these answers on Drupal.SE (to questions tagged with the Rules module).
I have heard that several people use the rules module to direct people to different pages on login, dependent upon their role, or just to do a general redirect to the page the person logged in from.
drupal.org/project/rules
You can:
Use the Login Destination module.
Let your users login at example.com/user?destination=some/path. This will redirect them to example.com/some/path after submitting the form.
Write a custom module, implementing hook_form_alter. It's explained here: drupal.org/node/236234.
Figured it out. So, you:
SETTING IT UP:
Create a PAGE,
Have the default login module ONLY display on the PAGE using the BLOCK config settings.
On load have BLOCKS set to ONLY display content to users of that ROLE.
ISSUES: Down side is that a user that has NOT logged in will see the page TITLE, and a user that is able to login will see the same page TITLE.
Please comment if that doesn't make sense, OR post another answer if there's a better solution. Thanks!!
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.