Jump to content

Custom Login Redirection


Recommended Posts

I am trying to figure out a way to do a custom login redirection. I want for when a user logs in for it to redirect to a different url other then the clientarea. As an example when a person logs in instead of redirecting to clientarea.php i would like for it to go to http://www.mainsite.com. Does anyone have any ideas on this or a module to handle this. Thanks in advance.

Link to comment
Share on other sites

yes you can do that, inside /includes/hooks folder create new file with any name like clientloginredirect.php for example, then copy the following code to it:

<?php

# Force Client Redirection After Logging In
function hook_forceClientLoginRedirect($vars){
global $CONFIG;
   # Add Redirection URL Here
   $URL = $CONFIG['SystemURL'];

   echo '<meta http-equiv="refresh" content="0; url='.$URL.'">';
   exit;
}
add_hook("ClientLogin", 1, "hook_forceClientLoginRedirect");

?>

 

at line #6 you can specify the URL you want to redirect your client to, since this happen whenever your clients login to client area they will redirected to this URL..

Link to comment
Share on other sites

yes you can do that, inside /includes/hooks folder create new file with any name like clientloginredirect.php for example, then copy the following code to it:

<?php

# Force Client Redirection After Logging In
function hook_forceClientLoginRedirect($vars){
global $CONFIG;
   # Add Redirection URL Here
   $URL = $CONFIG['SystemURL'];

   echo '<meta http-equiv="refresh" content="0; url='.$URL.'">';
   exit;
}
add_hook("ClientLogin", 1, "hook_forceClientLoginRedirect");

?>

 

at line #6 you can specify the URL you want to redirect your client to, since this happen whenever your clients login to client area they will redirected to this URL..

 

 

I tried this but now it says when i log in at the end of the url "clientarea.php?incorrect=true".

 

My question would be where or what information do i put in line 6. Say for example my whmcs url is secure.mysite.com and when the clients log in i want them redirected to demo.mysite.com? I put the url in between the quotes where you put system url.

Link to comment
Share on other sites

this "clientarea.php?incorrect=true" means you entered invalid account username/password, i wrote this code and tested it before sending it you, please try to login using valid client account..

 

in line #6 i set the WHMCS System URL you may change it to something like that "http://somehost.any/dir/file.php" or "file.php" or any other URL.

 

btw when your client loggedin in "secure.mysite.com" and redirected to "demo.mysite.com" it doesn't mean he will be loggedin in "demo.mysite.com"!! what exactly you try to do by this I may help you?

Link to comment
Share on other sites

It still logs me in and account is valid so not sure why it says incorrect-true when in fact it logs me in. I have a website at one url that is joomla and the other is whmcs. I installed joomla bridge and it has worked great for sharing login. All i want now is for the login redirection to work so when a user logs in it takes them back to the joomla site instead of the whmcs site. In the joomla site i have a link for them to look at the clientarea if they choose.

 

On line 6 do i keep the $CONFIG so it is like $URL = $CONFIG['http://demo.mysite.com']; or should line 6 be $URL = "http://demo.mysite.com";

 

Also thank you again for your help in this it has been driving me nuts and can not find anything in search results that is right or works.

Link to comment
Share on other sites

That seemed to work great I will play around with this now. Thank you again I learned alot today. Not just about what I needed but helped me to understand hooks a bunch better and how to use them as well. Def glad I posted and you answered me!

you welcome, i hope that i helped you with what you need..

Link to comment
Share on other sites

  • 8 months later...
  • 7 years later...
Hi,
It is my goal to create a hook that, when a new client clicks on the Complete Order button after first ordering, the client is forced to log into the client area and then redirected to my custom page without first seeing the homepage. Please note: This is only for new clients
Thanks in advance

 

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