benneth Posted March 2, 2020 Share Posted March 2, 2020 Would like to create a landing page for all users who are on any "cart.php" page. The purpose is to redirect users to "MyPage.php", a page with a contact form and "Need additional services? Fill out the form below, or call xyz". How can I do this? Thanks! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 2, 2020 Share Posted March 2, 2020 7 hours ago, benneth said: How can I do this? you don't want any existing client or new user to be able to access any cart page and redirect them elsewhere? if so, a hook similar to the one posted in the thread below would work... ... but in your case, it's more generic, so you would need to change that if statement to... if ($vars['filename'] === 'cart'){ and change clientarea.php to MyPage.php 0 Quote Link to comment Share on other sites More sharing options...
benneth Posted March 3, 2020 Author Share Posted March 3, 2020 (edited) EDIT: Even when client is not logged in, if a visitor tries visiting "/contact.php", it goes to the "/submitticket.php?step=2&deptid=1" URL // Hey Brian, Thanks for the feedback. I tried it, and initially, it worked! However, after about 5-10 minutes (perhaps after a cache clear?), when I click on "Order New Services", or any "cart.php?xyz"... the URL goes to: /submitticket.php?step=2&deptid=1 Here's the code, looked pretty straightforward. I put the code in my "/includes/hooks/helloworld.php" file. Any ideas? <?php # Redirect Cart Visitors Hook to Contact Form # Written by brian! function redirect_cart_vistors($vars) { if ($vars['filename'] === 'cart'){ header("Location: contact.php"); exit; } } add_hook("ClientAreaPageCart", 1, "redirect_cart_vistors"); ?> Edited March 3, 2020 by benneth Found that it's a macro effect (redirect from contact.php --> tickets page) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 4, 2020 Share Posted March 4, 2020 13 hours ago, benneth said: Any ideas? aah you want a hook to work for more than 5 minutes... 🤑 the hook code itself isn't the issue, it's your choice of redirection page. ➡️ if the hook was redirecting to a custom page (as per the question), it would work fine.... however, you chose to use contact.php which is a conditional page - e.g., clients cannot use that form to contact you (they would get redirected to a support department regardless of this hook), only non logged-in clients can use that page. if you want to test that, disable the hook (rename its extension to .php9), login as a client and try to go to contact.php - and you'll find that you'll get redirected to a support department. what you'll probably have to do is either... redirect everyone to the same support department (by changing the url in the hook).. redirect clients to a support dept, non-clients to contact.php (whmcs will do that anyway, but the hook could be tweaked to forward clients to a specific dept if required).. use a separate custom form for both. 0 Quote Link to comment Share on other sites More sharing options...
benneth Posted March 5, 2020 Author Share Posted March 5, 2020 Hey Brian, Looks like the issue was a setting under "General Settings". I had mistakenly entered an email for pre-sales email, instead of setting the ticketing email to Department-based emailing. All is working now! Thank you for your insight and help. 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.