Author Topic: How to change Registration completion redirection page  (Read 25509 times)

rb

  • Advanced
  • Full Member
  • *****
  • Posts: 1503
Re: How to change Registration completion redirection page
« Reply #15 on: December 24, 2009, 21:43:21 pm »
I believe the following hack will work.  Following a successful registration it will re-direct the customer to which ever web page you specify.  It will not display a "successful registration" message.  If your site requires customers to activate their account after receiving the email, this hack has no effect.

Make a copy of, then edit this file:
     administrator/components/com_virtuemart/classes/ps_shopper.php

In the function "add" (which adds a shopper to VM and Joomla), around line 467, find this:
Code: [Select]
// Redirect to the Checkout Page if the cart is not empty
if( !empty( $_SESSION['cart']['idx'])) {
$redirect_to_page = 'checkout.index';
} else {
$redirect_to_page = HOMEPAGE;
}
vmRedirect( $sess->url( 'index.php?page='.$redirect_to_page, false, false ), $VM_LANG->_('REG_COMPLETE') );

Replace the 5th line, substituting your desired web page, so the whole thing looks like this:

Code: [Select]
// Redirect to the Checkout Page if the cart is not empty
if( !empty( $_SESSION['cart']['idx'])) {
$redirect_to_page = 'checkout.index';
} else {
vmRedirect( 'http://www.YourWebPage.com' );
}
vmRedirect( $sess->url( 'index.php?page='.$redirect_to_page, false, false ), $VM_LANG->_('REG_COMPLETE') );

I have done some testing with this, but you should thoroughly test before going live with it (e.g., SSL, optional registration, etc).

bmanowitz

  • Beginner
  • *
  • Posts: 7
Re: How to change Registration completion redirection page
« Reply #16 on: December 24, 2009, 22:12:07 pm »
I believe the following hack will work.  Following a successful registration it will re-direct the customer to which ever web page you specify.  It will not display a "successful registration" message.  If your site requires customers to activate their account after receiving the email, this hack has no effect.

Make a copy of, then edit this file:
     administrator/components/com_virtuemart/classes/ps_shopper.php

In the function "add" (which adds a shopper to VM and Joomla), around line 467, find this:
Code: [Select]
// Redirect to the Checkout Page if the cart is not empty
if( !empty( $_SESSION['cart']['idx'])) {
$redirect_to_page = 'checkout.index';
} else {
$redirect_to_page = HOMEPAGE;
}
vmRedirect( $sess->url( 'index.php?page='.$redirect_to_page, false, false ), $VM_LANG->_('REG_COMPLETE') );

Replace the 5th line, substituting your desired web page, so the whole thing looks like this:

Code: [Select]
// Redirect to the Checkout Page if the cart is not empty
if( !empty( $_SESSION['cart']['idx'])) {
$redirect_to_page = 'checkout.index';
} else {
vmRedirect( 'http://www.YourWebPage.com' );
}
vmRedirect( $sess->url( 'index.php?page='.$redirect_to_page, false, false ), $VM_LANG->_('REG_COMPLETE') );

I have done some testing with this, but you should thoroughly test before going live with it (e.g., SSL, optional registration, etc).


Thank you so much, im going to try it out tonight.

One quick question though, just out of curiosity, why cant you just change the HOMEPAGE variable to "www.yoururl.com" as opposed to calling the vmRedirect() function. Ill defiantly give it a try as is, but if you feel like answering...it will quell my curiosity.

rb

  • Advanced
  • Full Member
  • *****
  • Posts: 1503
Re: How to change Registration completion redirection page
« Reply #17 on: December 25, 2009, 00:03:56 am »
why cant you just change the HOMEPAGE variable to "www.yoururl.com" as opposed to calling the vmRedirect() function.

HOMEPAGE is expected to be a PHP filename within VM, typically "shop.index".  If HOMEPAGE had a URL in it (and subsequently so did the variable $redirect_to_page), then the final statement in the code above would not redirect to that URL, but would stay in VM or create an error.

Laurelle

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 61
Re: How to change Registration completion redirection page
« Reply #18 on: December 31, 2009, 02:18:14 am »
I believe the following hack will work.  Following a successful registration it will re-direct the customer to which ever web page you specify.  It will not display a "successful registration" message.  If your site requires customers to activate their account after receiving the email, this hack has no effect.

Make a copy of, then edit this file:
     administrator/components/com_virtuemart/classes/ps_shopper.php

In the function "add" (which adds a shopper to VM and Joomla), around line 467, find this:
Code: [Select]
// Redirect to the Checkout Page if the cart is not empty
if( !empty( $_SESSION['cart']['idx'])) {
$redirect_to_page = 'checkout.index';
} else {
$redirect_to_page = HOMEPAGE;
}
vmRedirect( $sess->url( 'index.php?page='.$redirect_to_page, false, false ), $VM_LANG->_('REG_COMPLETE') );

Replace the 5th line, substituting your desired web page, so the whole thing looks like this:

Code: [Select]
// Redirect to the Checkout Page if the cart is not empty
if( !empty( $_SESSION['cart']['idx'])) {
$redirect_to_page = 'checkout.index';
} else {
vmRedirect( 'http://www.YourWebPage.com' );
}
vmRedirect( $sess->url( 'index.php?page='.$redirect_to_page, false, false ), $VM_LANG->_('REG_COMPLETE') );

I have done some testing with this, but you should thoroughly test before going live with it (e.g., SSL, optional registration, etc).


Thank you so much, im going to try it out tonight.

One quick question though, just out of curiosity, why cant you just change the HOMEPAGE variable to "www.yoururl.com" as opposed to calling the vmRedirect() function. Ill defiantly give it a try as is, but if you feel like answering...it will quell my curiosity.

Thank you so much for your help. That works great!

bmanowitz

  • Beginner
  • *
  • Posts: 7
Re: How to change Registration completion redirection page
« Reply #19 on: December 31, 2009, 03:20:32 am »
Truly a godsend!

revive

  • Jr. Member
  • **
  • Posts: 96
Re: How to change Registration completion redirection page
« Reply #20 on: January 05, 2010, 03:31:31 am »
Changing this:
Code: [Select]
$redirect_to_page = HOMEPAGE;
}
vmRedirect( $sess->url( 'index.php?page='.$redirect_to_page, false, false ), $VM_LANG->_('REG_COMPLETE') );


To this:
Code: [Select]
vmRedirect( 'http://www.YourWebPage.com' );
}
vmRedirect( $sess->url( 'index.php?page='.$redirect_to_page, false, false ), $VM_LANG->_('REG_COMPLETE') );

will create an error, and possibly more glitches as the vmRedirct is 'building the link using $redirect_to_page variable. vmRedirect is expecting to 'see' a page name, NOT a URL.

By changing HOMEPAGE to http://yourwebsite.com your final vmRedirect will look something like this:

Code: [Select]
vmRedirect( $sess->url( 'index.php?page='http://yourwebsite.com, false, false ), $VM_LANG->_('REG_COMPLETE') );

So the URL would return as:
Code: [Select]
http://yourwebsite.com/index.php?http://yourwebsite.com

not a good thing..

If u pass a URL to that variable as you suggested, I would venture to say that your user will experience problems someone in the process.. test this thoroughly and consider simply changing the vmRedirect $sess->url variable instead.

rb

  • Advanced
  • Full Member
  • *****
  • Posts: 1503
Re: How to change Registration completion redirection page
« Reply #21 on: January 05, 2010, 16:32:39 pm »
The posting above from "revive" is incorrect.

The hack, repeated here, does work properly and will not cause glitches.
Replace the line:
Code: [Select]
$redirect_to_page = HOMEPAGE;
With the line:
Code: [Select]
vmRedirect( 'http://www.YourWebPage.com' );

Notes to "revive":
The line
Code: [Select]
vmRedirect( 'http://www.YourWebPage.com' );does not cause an error.  This invocation of the function vmRedirect is NOT "building the link using the $redirect_to_page variable". When this vmRedirect is executed, it executes $mainframe->redirect (assuming Joomla 1.5 or greater).  $mainframe->redirect is an instance of JApplication, which in this case (where we have the leading http in the paramater $url) writes JavaScript to change the location.href to $url and then executes $mainframe->close which EXITs.  Therefore, it does not return and go on to execute the later vmRedirect.

Since 3 people had already tested it and reported it as working, please be more careful in future posts so as not to confuse subsequent readers of a thread.  If your own testing has turned up something new, more details should be provided instead of just stating this causes an error.


Your second point about addressing bmanowitz's question regarding changing HOMEPAGE is basically a repetition of the answer already given, although you have a minor error in that response.  The generated URL would not be the one you specified but rather would be:
Code: [Select]
http://yourwebsite.com/index.php?page=http://yourwebsite.com

revive

  • Jr. Member
  • **
  • Posts: 96
Re: How to change Registration completion redirection page
« Reply #22 on: January 05, 2010, 16:52:19 pm »
Wow.. 3 people have tested without issues (so far).. props. I guess that wealth of knowledge is exactly what we need for a hack to be valid. I'm kidding! Relax. All cynicism aside,.. my point was simply that, and don't get me wrong - I AM glad it's working for you - but we should continue to press on and find a real solution to this issue instead of trying to make the redirect fail, in essence, to get the desired results.

And thank you for correcting my error on the code snippet,. I missed typing in the page= portion. (See, that's what happens when I type too fast.. lol)


timbaker

  • Beginner
  • *
  • Posts: 11
    • rideride bike shop
Re: How to change Registration completion redirection page
« Reply #23 on: January 29, 2010, 12:18:52 pm »
just a small note
you can still add the registration message with this fix

vmRedirect( 'http://www.YourWebPage.com' , $VM_LANG->_('REG_COMPLETE') );

Sparky9292

  • Beginner
  • *
  • Posts: 29
Re: How to change Registration completion redirection page
« Reply #24 on: March 24, 2010, 20:38:40 pm »
Quote
If your site requires customers to activate their account after receiving the email, this hack has no effect.

Well I actually want my users to verify their email and get admin activation over email.   :-*

No one on my site can buy anything without approval.

So at the bottom of the add method, I've changed this:

Code: [Select]
if( !empty($my->id) || !empty($auth['user_id']) ) {
  vmRedirect( $sess->url( 'index.php?page=checkout.index', false, false ) );
}
else {
  $GLOBALS['page'] = 'shop.cart';
  $msg = strip_tags( $VM_LANG->_('REG_COMPLETE_ACTIVATE',false) );
  $vmLogger->info( $msg );
}

to this:

Code: [Select]
if( !empty($my->id) || !empty($auth['user_id']) ) {
  vmRedirect( $sess->url( 'index.php?page=checkout.index', false, false ) );
}
else { // Redirection after a new user registers.  Don't want to take them to the empty shopping cart.
  vmRedirect(URL.'index.php', $VM_LANG->_('REG_COMPLETE_ACTIVATE') );
}

The GLOBALS object is used for the caller of add to redirect within virtuemart.  I don't want to redirect to any page in virtuemart so this is useless and I want the control to exit after the redirect.  The vmlogger (which is documented) simply displays a message box.  However the second parameter for vmRedirect does that just fine.

BTW,  where the heck is the documentation for the vmRedirect function?  This would be really nice to have instead of just guessing.  Thanks to rb for stating that:
Quote
then executes $mainframe->close which EXITs.  Therefore, it does not return and go on to execute the later vmRedirect.

Thank you for that tidbit of info. Makes me feel a bit better.

BTW, timbaker, don't hardcode your URL.  I like to test on localhost first and then push changes live.  I would have to change that all of the time which would be annoying.

randomperson

  • Beginner
  • *
  • Posts: 16
Re: How to change Registration completion redirection page
« Reply #25 on: September 24, 2010, 13:09:46 pm »
Quote
If your site requires customers to activate their account after receiving the email, this hack has no effect.

Well I actually want my users to verify their email and get admin activation over email.   :-*

No one on my site can buy anything without approval.

So at the bottom of the add method, I've changed this:

Code: [Select]
if( !empty($my->id) || !empty($auth['user_id']) ) {
  vmRedirect( $sess->url( 'index.php?page=checkout.index', false, false ) );
}
else {
  $GLOBALS['page'] = 'shop.cart';
  $msg = strip_tags( $VM_LANG->_('REG_COMPLETE_ACTIVATE',false) );
  $vmLogger->info( $msg );
}

to this:

Code: [Select]
if( !empty($my->id) || !empty($auth['user_id']) ) {
  vmRedirect( $sess->url( 'index.php?page=checkout.index', false, false ) );
}
else { // Redirection after a new user registers.  Don't want to take them to the empty shopping cart.
  vmRedirect(URL.'index.php', $VM_LANG->_('REG_COMPLETE_ACTIVATE') );
}

The GLOBALS object is used for the caller of add to redirect within virtuemart.  I don't want to redirect to any page in virtuemart so this is useless and I want the control to exit after the redirect.  The vmlogger (which is documented) simply displays a message box.  However the second parameter for vmRedirect does that just fine.

BTW,  where the heck is the documentation for the vmRedirect function?  This would be really nice to have instead of just guessing.  Thanks to rb for stating that:
Quote
then executes $mainframe->close which EXITs.  Therefore, it does not return and go on to execute the later vmRedirect.

Thank you for that tidbit of info. Makes me feel a bit better.

BTW, timbaker, don't hardcode your URL.  I like to test on localhost first and then push changes live.  I would have to change that all of the time which would be annoying.
thank you so much for this

diablo

  • Beginner
  • *
  • Posts: 5
Re: How to change Registration completion redirection page
« Reply #26 on: February 01, 2011, 18:16:41 pm »
Code: [Select]
if( !empty( $_SESSION['cart']['idx'])) {
$redirect_to_page = $d['page'];
} else {
$redirect_to_page = HOMEPAGE;

}

$sess->url( 'index.php?page='.$redirect_to_page, false, false );
vmRedirect( 'http://YourSite.com', $VM_LANG->_('REG_COMPLETE') );

Keep user login after redirect

DansKO

  • Beginner
  • *
  • Posts: 38
Re: How to change Registration completion redirection page
« Reply #27 on: March 20, 2011, 13:32:19 pm »
so basically all you need to do is to create a new .php file in administrator/components/com_virtuemart/html/
(i.e."shop.registration_success.php")
and use that name-string to link to it.

Code: [Select]
$redirect_to_page = 'shop.registration_success';

best,
daniel

servicefly

  • Beginner
  • *
  • Posts: 17
Re: How to change Registration completion redirection page
« Reply #28 on: June 09, 2012, 00:29:37 am »
So wierd! None of this works for my installation: Joomla 1.5.23 VM 1.1.9...

Made the edits in ps_shopper.php just like mentioned but still get redirected from registration page to main store page upon success!

Has the files handling this changed in 1.1.9?

Any help is appreciated.