greetings, hope all is well.
i have exhausted every possible option to make this work and am at a standstill. all i am trying to achieve is to redirect a user to the previous page they were on before they registered.
first i wrote an extension that hooks to member_member_register. which does redirect after registration, however it seems to skip the automatic login after registration and does not log the user in. when i switch the hook to member_member_login_single, my redirect stops working period. nothing in the httpd log and no errors on screen. i am stumped.
so i tried going with SAEF for registration because it seems the code fairy removed the {form_declaration return=""} from the registration template, removing the ability for a non-technical user to specify the return address. anywho my SAEF gets a correct XID and RET value, but it still does not redirect. the registration info posts fine, just goes to that interstitial page that says you have registered and stops.
i am completely stumped.
here is my env: EE 1.6.3 member templates are running through main template engine
i can show you a url with the SAEF. the source looks fine. and again it posts/registers just fine, just refuses to redirect.
any help would be much much appreciated.
OK- first I’d just hack it and make sure that works. So basically- in mod.member_register.php around line 827- assuming there’s no forum:
$return = $PREFS->ini('site_url');
Change that- use the tracker array- docs and probably default to the home page.
OK- if that works? Then to avoid hacking- I’d use the last hook- member_member_register. But you’ll need to basically make sure to do EVERYTHING that happens after that point- and have it end script. Which I didn’t look at too closely, so can’t say how difficult that will be.
Also- shifting to ‘how to’. Might be better in the extensions forum- but I’m not dead sure that’s the way you’ll go, so will leave it in how to for now.
That help a little? It’s really a custom code issue.
Sorry for coming in on the end of this like this but I am too wondering about how to go about doing this. I did have a go at making an extension to handle this and did get it to log the person in successfully but as you say it seems quite hard to get them re-directed to a page you choose. Couple that with the person might be registering and the system is set to send them an e-mail and the whole thought of the extension just gets more difficult.
Robin, when you say “make sure to do EVERYTHING that happens after that point” this is the one thing that has always made me ask “How?”. What I mean by that is if I just do a direct copy-paste of the code from the core file then it will work no problems but as we aren’t allowed to do that due to then giving out code that is copyrighted then how do we go about doing that? What I mean to say is I’m not a fantastic coder like the dev team so when I look at the mountain of code that handles that function I really wouldn’t know where to start to re-create the code so that it does the same function but without giving out core code. Whilst I can copy-paste the code and get it to work I then wouldn’t be able to share this extension with anyone else if I am right in my thinking?
Just thought I would ask what we are supposed to do in that sort of a situation. Also please feel free to split this message off into a new thread if you like and linking to this one as I know on the forums you now have the “start a new thread like this one” once the thread is closed but I don’t see a link for doing that whilst the thread is live as it were 😉
Thanks.
Best wishes,
Mark
hey robin, i will try that. but in the meantime, i need to know why when i have a correct RET value, EE is not redirecting.
and hey mark, i have read all your previous posts on this topic, as well as everyone else’s. it would seem no one has successfully got this to work. if we have to copy any of their functions into our extension then they have failed at making a framework. maybe i think differently - but shouldn’t there be hooks for before and after ? so when i hook to member_member_login_finish i can redirect without any worries…
robin, thank you.
but
$return = $PREFS->ini('site_url');
only changes the url for which the return page is linked to :(
Thank You! Your registration has been successfully completed. You are logged-in and ready to begin using your new account. my.site.com (now has my specified href)
ok, lets forget the extension and hacking ee core files for a sec - and lets go back to the RET hidden input.
i am staring at this is my SAEF
<input type="hidden" name="RET" value="http://my.site.com/my/return/url" />
is this not correct ? it’s as if EE is just ignoring it …
hey mark, i have read all your previous posts on this topic, as well as everyone else’s. it would seem no one has successfully got this to work. if we have to copy any of their functions into our extension then they have failed at making a framework. maybe i think differently - but shouldn’t there be hooks for before and after ? so when i hook to member_member_login_finish i can redirect without any worries…
That’s what gets me as well. I’m not a fantastic coder as anyone here can tell just by looking at the extensions and plugins I have made 😉 but this one really got to me as I had a real need for this on a project and could never get it to work unless I copy-pasted many many lines of code from the core file which I know I wasn’t allowed to then offer this file for others to use which was a bit down-heartening really. As I’m not a fantastic coder trying to recreate all the code they have in there was just way above my head unfortunately.
robin, ok, lets forget the extension and hacking ee core files for a sec - and lets go back to the RET hidden input. i am staring at this is my SAEFis this not correct ? it’s as if EE is just ignoring it …<input type="hidden" name="RET" value="http://my.site.com/my/return/url" />
I don’t think the RET value gets sent back as there isn’t the provision in the ExpressionEngine tag for it. It does appear to be in the core file code but with no way of sending it to it unfortunately! There must be a reason for this I guess although I don’t think one has ever been mentioned by the dev team here. Would be nice to know if this could be added in once and for all or whether there is a definite reason why it wasn’t added in though.
Best wishes,
Mark
mark,
the RET param is being sent via with my http request. i am 100% percent sure of this. what EE is doing with the RET value is what i am unsure of. it seems to be ignoring it…
ughh, well back to modifying mod.member_register.php so if i drop my redirect code after the return line above, it works!
replace
$return = $PREFS->ini(‘site_url’);
with
$return = $PREFS->ini(‘site_url’); $ret = $SESS->tracker[‘2’]; $ret = preg_replace(‘/^\//’, ”, $ret); $ret = preg_replace(‘/\/$/’, ”, $ret); $ret = $FNS->create_url($ret, false, false); header(“Location: ” . $ret); exit();
i’ll settle for that for now.
cheers.
I think I’ll shift this to extensions. Basically- it’s using the output class to handle the message and the redirect.
$data = array( 'title' => $LANG->line('mbr_registration_complete'),
'heading' => $LANG->line('thank_you'),
'content' => $LANG->line('mbr_registration_completed')."\n\n".$message,
'redirect' => '',
'link' => array($return, $site_name)
);
$OUT->show_message($data);
So- to get the link right- you set the $return and $site_name as desired. Right link should be there if defined using tracker array. And I missed the redirect- there isn’t one because it’s blank. Stick the same $return in there, I bet it will do the standard redirect as desired.
The RET parameter just isn’t doing anything here- that’s why playing with the post data isn’t going to affect it.
Now- I’d have no qualms making an extension and using it myself and on client sites. Distributing it- because I don’t see a way around basically copying all of the code from the hook on down and then tweaking it- well, I’d just ask the dev crew before distributing. They’re reasonable about such things- and if they didn’t want it publicly distributed, they’d let you know and let you know why. But I’ve asked on stuff that duplicated a fair bit of code, and they were cool with it.
So- if you need it for your own use, I’d make the extension to avoid having to maintain a hack. And then I’d just ask the crew if it’s cool to distribute.
Make sense?
But I’ve asked on stuff that duplicated a fair bit of code, and they were cool with it. So- if you need it for your own use, I’d make the extension to avoid having to maintain a hack. And then I’d just ask the crew if it’s cool to distribute. Make sense?
Not with one of mine unfortunately :down: I didn’t realise at the time that something I had done was not allowed as I had basically copied a lot of the core code and so the file was taken down from the forums and I was told off!! 😉
Would be nice to get a definitive answer from someone on the Dev team as to how much we are allowed to copy and distribute or what we can do instead of that when we aren’t fantastic coders like they are 😉
Best wishes,
Mark
thanks again for the replies.
if i make it to $OUT->show_message($data); then i have gone too far. i need my code to run before that display class does its thing, but after EE has logged the user in.
i believe this is the order:
member registers member is automatically logged in –> my extension needs to redirect confirmation page is shown
inserting this at line 828 before the dsp data array gets constructed seems to be the only way i can get the desired functionality.
$ret = $SESS->tracker['2'];
$ret = preg_replace('/^\//', '', $ret);
$ret = preg_replace('/\/$/', '', $ret);
$ret = $FNS->create_url($ret, false, false);
header("Location: " . $ret);
exit();
:(
😉 I try to ask before distributing it! That’s likely to have better luck. But yep- it’s going to boil down to a case-by-case decision, so just ask them before releasing it into the wild.
Righto will do in future. Thanks Robin!
So what do you think the chances of me copying the whole of ExpressionEngine and placing it into an extension and re-distributing that would be then? 😉
Mark
As a quick update to all of this and a slight aside the other day I got this working and posted some code on how to do so. I just tried this with a registration form and it also works. Of course you are going to need to visit your member/register form first and copy out the needed form code as I’m not sure if you can add in Javascript to the member/register form although to tell the truth I haven’t actually tried yet 😉
Anyway I copied the code from the rendered registration form and tied it in using the same AJAX method as in the link above and it all worked famously!! At the moment the code I have posted at that link just brings up an alert but you can easily just place [removed] there instead to re-direct after registration.
Might be handy for some people so thought I would just post the idea very quickly.
Best wishes,
Mark
thanks mark. i’m a little anal though when it comes to having to do something client side that i want to happen server side. so i’m gonna stick with the hack i got for now, and when i have time go back to my extension and get that working as intended.
Yeah I know what you mean on that one. Might be helpful to some people who don’t want to hack though. I’m thinking I might look back into this one again. I might just create the extension for my own use for now and if I am allowed to release it then will do but I think that I am going to probably have to copy too much of the internal code for it to be allowed to be released unfortunately.
Shame really as this is something a lot of people need.
Thanks for posting the code (hack) above, will keep that in mind.
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.