I'm trying to get it so that when a user registers, they get taken to someplace other than the home page. This is a temporary thing, so I'm just hacking /includes/form.inc on line 196, just before the return to the drupal_submit_form() function. for now I've jsut hardcoded a
$goto = (empty($goto)) ? "forum" : $goto;
That works fine, but I would prefer to do it without a hack, but I'm just not seeing how to do it. Any suggestions?
As a warning to future readers, this hack will redirect pretty much any form submission that sends one to the home page, not just registration. In my case that's actually what I want because only the forums run on Drupal right now on the site in question, so I want people to always end up either there or at the drupal-designated page after any form submisison, so that's my rationale in this very specific situation. May not work for you.
Comments
Module: Login Destination
Have you looked at the Login Destination module?
http://drupal.org/node/69051
Might do the trick for you without modifying the core :)
Great! That's such a simple
Great! That's such a simple module that I think I should be able to make a registration_destination module off that module.
Yosemite Explorer - hiking and climbing in Yosemite (drupal)
Okay, I made a new module
I took Moshe's module and made a few additions so that
1. you can set the landing page for both the login page and the registration page
2. you can set the relevant paths in the admin->settings->landing_page
Not sure if Moshe would want to just add this to his module, in which case it isn't really named right anymore, or whether it should be it's own module. I currently call it "landing_page"
Here's the code. Basically, install is simple.
1. Create a file called landing_page.module
2. copy the code into that file
3. put the file either in /modules or /modules/landing_page
4. go to admin->modules and enable the landing_page module
5. go to admin->settings->landing_page and set your paths.
Yosemite Explorer - hiking and climbing in Yosemite (drupal)
beautiful, but ..
you shouldnt be putting the "?>" at the end.
i spent quite some time getting blank screens before i realised i have to remove the end quotes.
on the whole beautiful and simpe .. proved very useful ..
in fact this seems so primary i wonder why it isnt built into the core itself ...
question:
not that i know too much of the drupal core, but .. do hacks like these ending up affecting the speed of the whole system itself? as i guess the above function will now be called almost everytime a form is submitted.. does that affect performance significantly?
thanks nonetheless,
i'm going with it as this module is just what i was looking for!
rajesh
Every module file that
Every module file that invokes php should close it, so the ?> should be necessary, so what you're saying is incorrect (i.e. that I shouldn't have it, though of course I believe you were getting errors.
That begs the question, though, of why this caused you problems. I'm trying to remember whether or not I made any debug changes since posting that, but I don't think so. I don't suppose you still have any debug output (blank screen probalby means that you're having debug output logged rather than displayed). My guess is that somehow you ended up with two instances of the ?> because your text editor does that when you create a new PHP file. Is that possible?
Anyway, I don't think a little thing like this will slow drupal down much, but yes, some modules can cause a big drag on the server. Anything that takes a bunch of DB calls to function is going to have a bigger effect. The only real solution is to get XDebug and CacheGrind and see what functions use the most resources and see how you can optimize those.
Yosemite Explorer - hiking and climbing in Yosemite (drupal)
Actually closing PHP tag is optional
The closing PHP tag is optional an current Drupal coding standards suggest leaving it off. You can read about this at http://drupal.org/node/545, which include a link to a more in depth discussion of the topic.
Thanks!
For all the help ..
Great link nevets
I stand corrected. I'm one of those people who always use braces even for one-line statements and have always used the ?> closing tag. But indeed it turns out that as of 4.7 the preferred way to code for Drupal is without it and the official PHP manual recommends leaving it off. I have to say the rationale is convincing - it does no harm and can do some good with avoiding "headers already sent" errors.
Thanks for the heads up. I'll change my coding style.
That perhaps explains the problems the other poster was having - if he pasted it into his editor with whitespace at the end, he would have gotten the error and if he has his server set not to display errors, a blank screen.
Yosemite Explorer - hiking and climbing in Yosemite (drupal)
it's not working in my
it's not working in my setup. it's 4.7 on RH linux. it even does not show description and no link on settings. then i entered manually entering URL. but it didn't work.
please be a little but more
please be a little but more desciptive.
1. what do you mean by "manually entering URL"?
2. did you try removing the ?> at the end of the module?
yes of course. 1.
yes of course.
1. http://site.com/admin/settings/landing. shows nothing only save and back to default buttons.
2. yes i did.
interestingly, when i disable this module and enable login_destination module it works. the problem with login_destination is that when you change destination path it does only recognize the first entered one.
thanks
URL problems
Actually, it seems that I have a problem with it too. It logs me in fine from the login page, but not from the login block. Not sure why that would be.
[edit: I take it back - it's working fine for me now and must have been working fine before since I haven't had complaints from the site owner]
As for the rest, the settings part works fine for me, so I don't know what's happening there. One thing - what did you call the module file? You are using the URL /landing not landing_page. Is that what you want?
Yosemite Explorer - hiking and climbing in Yosemite (drupal)
i tried from login page it
i tried from login page it worked! but when i use login block it's not working at all. Rick did you make something special to work again from login block?
i could now enter settings file with landing_page and saved settings is working from login page. but still there is no link in settings and no description in modules page. it may be a small bug.
now i verified that this module has the same bug as login_destination. even if you change destination value it only remembers the first one regardless of any new value.
I haven't figured this out
It appears that if you try to log in from a page where you are denied access (i.e. you go to /admin or /logout when you're logged out anyway) it fails. If you go to a page that you could access anyway without being logged in, it works for me, whether from the login block or from the login page.
This is getting quite annoying. Can't do anything more on it this morning, but I will spend some time on it this afternoon. Maybe I'll drop a PM to Moshe and see if he can help out since it's probably dead obvious what the problem is.
Tom
Yosemite Explorer - hiking and climbing in Yosemite (drupal)
Any success, Tom?
Any success, Tom?
I haven't really had time to
I haven't really had time to get back to it yet. I'll post here for sure when I do. Also, feel free to drop me a PM so you'll be in my email so I can send you anything I learn.
Yosemite Explorer - hiking and climbing in Yosemite (drupal)
Change 'access denied' for logged-in users on registration page
I was trying to change the Access Denied page that users receive if they find their way to the user/register page while they are logged in. I wanted it a redirect to the user page or anything else, but after reading this thread I'll just avoid hardcoding the registration link anywhere.
It shouldn't be so hard to get rid of unnecessary access denied pages! Is it better to submit a feature request now, or wait for 5.0? I haven't yet checked if this is the way the user/register page works in CVS.
~ben
Agaric Design Collective, http://AgaricDesign.com - "Open Source Web Development"
benjamin, Agaric
I think redirecting on access denied is good
I think redirecting to the user page or the home page on access denied would solve the problem with my little module and probably other issues. If that is the way it works in 5.0, then I'll make this into a patch to Moshe's module. Otherwise I will just keep this as a thread here until I can get it worked out (or someone else can).
Yosemite Explorer - hiking and climbing in Yosemite (drupal)
Perfect - thanks!
This worked perfectly for me, first time, no tweaking or hacking at all required!
Many thanks for this!
Steve
How in 5.x?
Anyone figure this out for 5.x? Whats the best solution for controlling first login?
logintoboggan module may
logintoboggan module may also be worth a look - has option to control where user is sent after registration (but not login, from what I can see)! Anyway may give some ideas for custom module.
gpk
----
www.alexoria.co.uk
for 5.x
And don't forget the .info file
The module seemingly works
The module seemingly works fine, but when I enter in the path for a user to be redirected to after registration, it does not work properly. I specify the path as user/, but when I register an account to test, the user does not actually get logged in, I go to the default user/register page, and the url is mysite.com/user/23049201 or some numbers which make no sense.
I did make an info file, and the administration menu of the module works fine...
>but when I register an
>but when I register an account to test, the user does not actually get logged in
As implemented here, registering does not automatically log you in. See prior comment about logintoboggan.
You might want to have a look down the list of modules here http://drupal.org/node/206666#DRUPAL-5 since there may now be something there to do what you want, if you aren't comfortable hacking this code.
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
for Drupal 6?
Hi,
This worked very well for me for Drupal 5.
Anyone has this working for D 6 already?
d6 solution
http://drupal.org/node/151543#comment-1370594 worked for me in d6. here's some sample code from my module:
The cleanest way to do this
The cleanest way to do this in D6, if all you want is to set a default redirect for user/register, is something like the following:
This allows you to still override it with "?destination=path" if you need to.
So, this goes in
So, this goes in template.php?
You would need to put that in
You would need to put that in a custom module.
gpk
----
www.alexoria.co.uk