Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-01-2009, 04:14 AM
Ludnix Ludnix is offline
 
Join Date: Dec 2005
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Register.php redirect to previous page?

I'm wondering if there is an option in vbulletin to have register.php redirect the user to their previous page on completion. I don't require email verification on my forum so it would be great if once they were registered it would take them to the original page the clicked the register link on rather than dumping them on the forum index.

I've seen a post about how to modify register.php to redirect somewhere else but I before I start changing register.php I thought I better make sure this isn't an option in the control panel or something.
Reply With Quote
  #2  
Old 07-01-2009, 08:00 AM
Saurdo Saurdo is offline
 
Join Date: Nov 2005
Location: Eureka, California
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I helped Ludnix out with his question.

Instead of doing this the smart way, which involves putting a hidden value on the registration page and then carrying that value throughout the registration process, I decided to take the easy (and fast) route and use a temporary cookie to store my data.

In register.php, right under this line:
PHP Code:
if ($_REQUEST['do'] == 'signup')

I put this code:
PHP Code:
setcookie('register_referrer'$_SERVER['HTTP_REFERER'], 0'/'); 
Might be a good idea to encode the referrer as well.

Then, after the user completes registration. The task is to redirect them to whatever that cookie value is.

So I found this line:
PHP Code:
eval(standard_error(fetch_error('registration_complete'$username$vbulletin->session->vars['sessionurl'], $vbulletin->options['bburl'] . '/' $vbulletin->options['forumhome'] . '.php'), ''false)); 
And replaced it with this:
PHP Code:
if(strlen($_COOKIE['register_referrer']) > 0){
                             
$vbulletin->url $_COOKIE['register_referrer']; 
                             eval(
print_standard_redirect('registration_complete')); 
                        }
                        else{
                            eval(
standard_error(fetch_error('registration_complete'$username$vbulletin->session->vars['sessionurl'], $vbulletin->options['bburl'] . '/' $vbulletin->options['forumhome'] . '.php'), ''false));
                        } 
Pretty sure $vbulletin->url is just a header redirect.

If you want, you can then delete your cookie:
PHP Code:
setcookie('register_referrer'''time()-3000'/'); 
and everything works and now everyone is happy.
Reply With Quote
  #3  
Old 07-01-2009, 08:31 AM
DragonBlade's Avatar
DragonBlade DragonBlade is offline
 
Join Date: May 2006
Posts: 189
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bit of advice?

Next time, if you can avoid it, don't change the hard-code. :3 Instead, use the Plugin/Hook system that vBulletin created for us. This is because any changes you make directly to the file can and will be over-written upon a forum update.

The hook in question you should use is register_signup.


For those wishing to do this to their forums, go to your AdminCP, "Add a New Plugin", choose 'register_signup' as the hook location (title it whatever you want).

You can use the same code Saurdo created above in that location:
PHP Code:
setcookie('register_referrer'$_SERVER['HTTP_REFERER'], 0'/'); 

For the actual redirect, create another Plugin, and use the Hook Location register_addmember_complete. In this hook, use the following code:
PHP Code:
if (!$vbulletin->GPC['coppauser'])
{
  
// CLEAN THE COOKIE DATA!  Not particularly important here, but it's good practice. ;)
  
$vbulletin->input->clean_gpc('c''register_referrer'TYPE_STR);
  
$vbulletin->url = ($vbulletin->GPC['register_referrer']) ? $vbulletin->GPC['register_referrer'] : $vbulletin->url;

Reply With Quote
  #4  
Old 07-01-2009, 08:52 AM
Saurdo Saurdo is offline
 
Join Date: Nov 2005
Location: Eureka, California
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't have any experience modifying vbulletin, hence why I didn't want to learn what register.php was doing, but you certainly make a good point. It would be annoying to have to fix this whenever the register.php file is updated. I was kind of using this old thread to help me find where I needed to edit. (apparently I failed to read the last post though)

Thanks for the tip. I am definitely going to move my code to the plugin system and use it for any modifications I do in the future.
Reply With Quote
  #5  
Old 07-01-2009, 02:35 PM
DragonBlade's Avatar
DragonBlade DragonBlade is offline
 
Join Date: May 2006
Posts: 189
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great. :3

Just look for them hook locations in the code whenever you want to modify something or add functionality.

Sometimes you just can't avoid making a direct hack to the file, but most of the time you can get something done with plugins that you need to. Plugins are great for two reasons--that bit about updating that I mentioned, and so that you can turn the plugins on and off if there might be a problem somewhere.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:41 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06533 seconds
  • Memory Usage 2,223KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete