jmiller48647 Posted March 3, 2015 Share Posted March 3, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 3, 2015 Share Posted March 3, 2015 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.. 0 Quote Link to comment Share on other sites More sharing options...
jmiller48647 Posted March 3, 2015 Author Share Posted March 3, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 3, 2015 Share Posted March 3, 2015 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? 0 Quote Link to comment Share on other sites More sharing options...
jmiller48647 Posted March 4, 2015 Author Share Posted March 4, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 4, 2015 Share Posted March 4, 2015 change it to something like this: $URL = 'http://demo.mysite.com'; and you're welcome 0 Quote Link to comment Share on other sites More sharing options...
jmiller48647 Posted March 4, 2015 Author Share Posted March 4, 2015 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! 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 4, 2015 Share Posted March 4, 2015 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.. 0 Quote Link to comment Share on other sites More sharing options...
AndyW Posted November 13, 2015 Share Posted November 13, 2015 you welcome, i hope that i helped you with what you need.. @sentq I need to do the redirection for specific clients only. Could you recommend suitable modification? 0 Quote Link to comment Share on other sites More sharing options...
Rahat_Arif Posted September 27, 2023 Share Posted September 27, 2023 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 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.