Jump to content

Redirecting to main web page


Recommended Posts

Hi Thomas,

On 26/11/2019 at 06:00, Thomasmcdaniel9 said:

once I leave my main website to the billing or domain search area I would like to click Home button and redirect back to my home page not the whmcs theme home page.

you can't change that from the admin settings, you would need to use an action hook (a php file that you upload to /includes/hooks) and change the link via that method.

the logo will usually direct back to the main site, or if it doesn't, that can be changed by editing the template as per the other thread,

I posted a hook in the thread below that would change the home button to redirect to clientarea.php for clients that were not logged in - in your case, you would change the 'clientarea.php' part of the hook to the URL of your site.

as I mentioned in that thread, when a user is not logged in, the home button redirects them to the index page of whmcs; when they are logged in, it redirects them to clientarea.php - so the above hook only changes the URL for those that are not logged in; for those that are, they will still be redirected to clientarea.php as before... if you wanted to change the URL of that Home button for everyone, you would just simplify the IF statement...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	if (!is_null($primaryNavbar->getChild('Home'))) {
            $primaryNavbar->getChild('Home')->setUri('https://google.com');
	}
});

what you might need to do is have a think about where this button redirects to, and for which users (e.g whether they are logged in or not) - because with this home button changed, logged in users would have no quick way to get back to the clientarea.php (other than clicking back in the browser)... you could add another menu button, using a hook, that went to your real home page, but as I say, you need to think about the navigation process for the user and how best not to confuse them!

Link to comment
Share on other sites

3 hours ago, brian! said:

Hi Thomas,

you can't change that from the admin settings, you would need to use an action hook (a php file that you upload to /includes/hooks) and change the link via that method.

the logo will usually direct back to the main site, or if it doesn't, that can be changed by editing the template as per the other thread,

I posted a hook in the thread below that would change the home button to redirect to clientarea.php for clients that were not logged in - in your case, you would change the 'clientarea.php' part of the hook to the URL of your site.

as I mentioned in that thread, when a user is not logged in, the home button redirects them to the index page of whmcs; when they are logged in, it redirects them to clientarea.php - so the above hook only changes the URL for those that are not logged in; for those that are, they will still be redirected to clientarea.php as before... if you wanted to change the URL of that Home button for everyone, you would just simplify the IF statement...


<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	if (!is_null($primaryNavbar->getChild('Home'))) {
            $primaryNavbar->getChild('Home')->setUri('https://google.com');
	}
});

what you might need to do is have a think about where this button redirects to, and for which users (e.g whether they are logged in or not) - because with this home button changed, logged in users would have no quick way to get back to the clientarea.php (other than clicking back in the browser)... you could add another menu button, using a hook, that went to your real home page, but as I say, you need to think about the navigation process for the user and how best not to confuse them!

Thanks Brian . the only issue i was having was finding  the file that i needed to insert the code into . in my case in Cpanel  file manager. { /Home/ Bililling.Mywebsitesubdomain/Includes/hooks/home.php } That is the file i had to modify but it works  perfect  

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    $navItem = $primaryNavbar->getChild('Home');
    if (is_null($navItem)) {
        return;
    }

    $navItem->setUri('https://YOURWEBSITE.com/');

});

Link to comment
Share on other sites

21 hours ago, Thomasmcdaniel9 said:

the only issue i was having was finding  the file that i needed to insert the code into . in my case in Cpanel  file manager.

I assumed you were going to create a new file - but if there was already an existing hook file there, and you were able to modify it and it works, then it's all good. 🙂

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