View Full Version : Triggering code on registration completion
Jon12345
03-27-2012, 01:23 PM
I'm noticing that the registration page - even though there are several steps - seems to be all on the same page, even the "thank you for registering" part.
This is causing me a headache! I want to put some tracking code that is only triggered when someone is finally registered.
How can I do that, considering its all on one page?
Thanks,
Jon
You'd have to check the 'do' parameter which can either be on the url or part of the posted information. How were you planning to add tracking code?
Jon12345
03-27-2012, 01:37 PM
The code I need to add - that should only get triggered on registration completion - is just a few lines of javascript.
There must be code in the template that gets triggered to display the thank you text, but I can't seem to see any if statements in there. I find it a bit confusing! I would have thought there would be something like this...
<IF>$registered="Yes":
show text
</IF>
But I can't see anything like that.
If each step of the registration process was on a seperate page, it would be easy to implement.
If you're talking about the "Your registration is now complete" message, that's actually an "error" message page that the user is redirected to, and the text is a phrase. But it's html so you might be able to edit that phrase and put in a <script> tag for your js.
Jon12345
03-27-2012, 01:46 PM
Oh wow, I never knew that. You must know your stuff kh99! So phrases can have embedded code then? Its certainly given me food for thought.
I'm also hoping to find a plugin so that I can have registration on one page too, so it includes forum rules and age.
Oh wow, I never knew that. You must know your stuff kh99! So phrases can have embedded code then?
It depends what the phrase is used for. I think most are html so you can put in anything you could put in html, others are used for email so you can't really include html. As far as me "knowing my stuff" the fact is that I have to go and read the php code to answer a lot of questions, so it only looks like I know this stuff. :)
Jon12345
03-27-2012, 02:00 PM
Well, if its any consolation, I've been reading the php code for ages and I'm finding it a bit mind bloggling! The funny thing is, when I go to phrase search and put in a phrase, I still can't find the location of the phrase variable in the template.
e.g. "Your registration is now complete" is the phrase, registration_complete is the variable. I go to Search Templates and enter in registration_complete. I do the search but nothing comes up. Puzzled!
Lower down in that box there are some "Search in..." radio buttons, you have to choose the 2nd or 3rd if you want to search for phrase variable names.
Jon12345
03-27-2012, 02:18 PM
I've only got Search Titles Only. Or do you mean I need to go the the Find and Replace section?
Pandemikk
03-27-2012, 02:29 PM
register_member_complete
That's the hook. Simply add echo 'html code here'; to that hook. Any code (like javascript) in that will be outputted to the browser.
Let me know if that hook isn't available in vB3. I'm going based off vB4.
I've only got Search Titles Only. Or do you mean I need to go the the Find and Replace section?
If you go to the "Search in Phrases" page, you should find some radio buttons "Phrase Text Only" and "Phrase Variable Name Only". "Phrase Text Only" is selected by default so you won't find the variable name.
register_member_complete
That's the hook. Simply add echo 'html code here'; to that hook. Any code (like javascript) in that will be outputted to the browser.
Let me know if that hook isn't available in vB3. I'm going based off vB4.
Actually what I said above was wrong, it's a redirect to an error page, but it does print out a phrase by calling the standard_error() function. In any case, while you could echo html code to the browser at that hook, it would happen before anything else was output so I think you'd pretty much have to output and entire html document and exit (in which case you'd be bypassing the vb shutdown code - which might not be a major problem, but just so you know...).
Pandemikk
03-27-2012, 02:52 PM
Output buffering is something I didn't think of. If you add vbflush(); after that echo statement it should output to the browser without messing up the layout.
But this is vB we're talking about, sometimes things don't work out that simple.
I'm not sure if there's any template hooks in there either (doubt it).
I'm not completely sure without trying it, but I don't think it's so much a matter of buffering of things you "echo" as the fact that vb normally doesn't output anything until near the end of the script, so even if you called vbflush() or otherwise succeeded in causing output, it would still happen before any of the normal vb output.
Pandemikk
03-27-2012, 03:24 PM
Yeah, you're right. It's not very smart to echo HTML before the page is even outputted. Going to get a screwed up looking page. Should stop posting when I just woke up.
I decided to look into the code instead of making random guesses. I don't think it's possible to add your own HTML into the registration complete page without hacking into the files. Your best bet would track sessions that registered then show the code for them.
If you only want them to get the code once you'll have to revert the field that tracks the sessions.
Jon12345
03-27-2012, 03:36 PM
Ok, now I am confused again! Does this mean I can't put the javascript into the phrase as suggested by kh99?
I think that will work (although I'm not 100% sure because I haven't tried it). But I think just putting code to echo it in a plugin might not work right. But you know, why not try it both ways - it can't really hurt anything (unless you're doing it on a busy live site).
Edit: oh, I missed Pandemikk's last post, I guess we agree that the echo thing probably isn't a good idea. I still think my idea might work, but maybe there's a better way.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.