View Single Post
  #155  
Old 12-11-2012, 07:28 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: common if/then modifications I make to x-cart...

Quote:
Originally Posted by xtech
Hi Mike,
Can you please look into this matter?
I am helping you, but I am also trying to get you to understand. I am willing to help for free, but not simply provide the code. This is not paid support.

I am trying to guide you, so that you can make modifications like this without help. Remember how we solved this last time? We are going to do the same!

Open up your /include/login.php Take a look at the file and actually read it, Open it up in a real code editor like Notepad++. Very near to the top of the file, we see:
Code:
if ($REQUEST_METHOD == 'POST') {
This starts the actions that are supposed to happen when a user "Posts" the form submitting their credentials. Next see (near line 84 in my file)
Code:
if ($mode == 'login') {
This IF statement is the main meat of this file. You can see its closing bracket, down around line 440 (in my file). First you see some error checking being performed, next you see the Image verification for Captcha.

Then it checks to see if their if the user exists and if the account is active or suspended (lines 117, 134). From line 141 down to about 229, you can see it performing functions for admin users, suspending accounts that are inactive, forcing password changes, and checking for admin IP restrictions.

Line 231 checks the password, but near line 243 we see this:
Code:
if ($allow_login) {
Now we are getting close! See the next statement near line 259:
Code:
if ($login_type == 'C') {

Near line 264 we see the note // Redirect to saved URL
After that you can see it checking for cart contents and remembered data, and finally near line 286:
Code:
$redirect_url = $remember_data['URL'];

If you use CTRL F to search in the file for this variable "$redirect_url", you will see it mentioned in several places. There are several points along this chain that you can use our code from before:
Code:
if ($custom == 'yes') { $script = 'pages.php?pageid=7'; }else{ $script = 'address_book.php'; }
But it will have to be changed. Consider this code:
Code:
if ($custom == 'yes') { $redirect_url = 'pages.php?pageid=7'; }
You can see several examples of this type of logic being applied throughout the existing code. Now we know what code we want to insert, we just have to find the right place to put it.You should be wondering, where is this information from this variable used, so I can cut it off and have my code take priority?

Look down through the document. See:
Code:
func_header_location($redirect_url);
Suspicious right? What happens if you place the code directly above this statement? (I haven't tried it)

Now don't forget to include the ?custom=yes at the end of your link.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote