Jump to content

custom redirect after login


MACscr

Recommended Posts

dologin.php?goto=custom no longer works? It only redirects you to the clientarea and not the custom page that was specified. Why? What should we do instead?

 

I found another thread with this topic, but for some reason there was no way to reply to it even though it wasnt locked.

Link to comment
Share on other sites

I am not sure why this is not working, but what I did is create a php file named go and placed it in my whmcs root directory

<?php
 header("Location: http://www.mysite.com");
?> 

 

I utilize this on my homepage so that when someone logs in from my homepage they are not redirected to another page it simply changes the login box to the links provided and the dologin.php?goto=go does the trick

 

I would think as long as you have the .php file in your main directory that it should forward to that page, I am not utilizing any "custom whmcs pages" so I am not sure how that worked in the past.

 

Hope this is somewhat helpful for a work around...

 

Now if I could just get the logout to utilize the goto command that would be nice :)

Edited by herpherp
Link to comment
Share on other sites

I am not sure why this is not working, but what I did is create a php file named go and placed it in my whmcs root directory

<?php
 header("Location: http://www.mysite.com");
?> 

 

I utilize this on my homepage so that when someone logs in from my homepage they are not redirected to another page it simply changes the login box to the links provided and the dologin.php?goto=go does the trick

 

I would think as long as you have the .php file in your main directory that it should forward to that page, I am not utilizing any "custom whmcs pages" so I am not sure how that worked in the past.

 

Hope this is somewhat helpful for a work around...

 

Now if I could just get the logout to utilize the goto command that would be nice :)

 

so this method you mentioned is working for you with 3.7.2? If so, then goto is obviously working and its something else.

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

I had the same problem and I make the next tricky solution (at the moment it works for me):

 

In your custompage.php put:

//...
if ($_SESSION['uid']) {
 # User is Logged In - put any code you like here
}
else{
 # User is NOT Logged In
 # Define the template filename to be used without the .tpl extension
 $templatefile = "login";
 # To assign variables in Smarty use the following syntax. This can then be used as {$variablename} in the template
 setcookie('mycustomgoto', 'custompage.php', 0, '/');
 $smartyvalues["formaction"] = 'dologin.php?goto=clientarea';
 $smartyvalues["incorrect"] = '';
 $smartyvalues["username"] = '';
 $smartyvalues["password"] = '';
 $smartyvalues["rememberme"] = '';
}
//...

And in template file header.tpl write at the begin of the file:

{if $loggedin && $pagetitle == $LANG.clientareatitle}
{php}
 global $smarty;
 $cgt = $_COOKIE['mycustomgoto'];
 setcookie('mycustomgoto', '', -3600, '/'); // Don't need it anymore
 if($cgt){
   $ssluri = $smarty->get_template_vars('systemsslurl');
   $redirecturi = $ssluri ? $ssluri : $smarty->get_template_vars('systemurl');
   header("Location: $redirecturi/$cgt"); /* Redirect browser */
 }
{/php}
{/if}

 

I know that it is not the best solution, but works. Only three comments:

1.- The browser must has the cookie activated.

2.- Login data is send plain without https.

3.- If you have ssl access to your whmcs client area, IE shows a ssl warning redirection.

 

2 and 3 can be solved making all pages https (view http://forum.whmcs.com/showthread.php?t=8481), and 1, in my case is a requirement for other issues and neither is a problem.

 

Hope this help, and any advice will be welcomed.

 

Regards.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated