Jump to content

Change "Home" URL


Recommended Posts

I moved my installation to a sub-directory with it own sub-name now.

I need to change the "Home" URL from the default /index.php to https://starbursthsoting.com

Looked at: https://developers.whmcs.com/themes/navigation/
But am confused, on what to call the file and where to save it.

If someone could double check, I think I have it correct below:

 

<?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://starbursthosting.com');

});

Edited by StarburstHosting
Link to comment
Share on other sites

  On 11/15/2020 at 11:12 AM, Kian said:

Setup > General Settings > General. Change Domain and WHMCS System URL accordingly.

Expand  

Tried that. 😕

Domain is set to https://starbursthosting.com

WHMCS System URL is set to https://portal.starbursthosting.com


But Home still takes you to https://portal.starbursthosting.com/index.php

Link to comment
Share on other sites

  On 11/15/2020 at 11:12 AM, Kian said:

Setup > General Settings > General. Change Domain and WHMCS System URL accordingly.

Expand  

I read the question more as he wants to redirect the home button to the parent site without the included index.php - changing the system URL from the existing subdomain URL where WHMCS is now hosted wouldn't do that and would probably stop WHMCS from working.

  On 11/15/2020 at 6:26 AM, StarburstHosting said:

But am confused, on what to call the file and where to save it.

Expand  

it needs to be a .php file in the /includes/hooks directory - you could call it "navbar_home.php" and then paste the above code into it and save.

  On 11/15/2020 at 6:26 AM, StarburstHosting said:

If someone could double check, I think I have it correct below:

Expand  

it's not the way I would do it, but it would work.

one thing worth mentioning is that when a user is logged in, that "home" button in the portal would redirect to clientarea.php (e.g the client area home page) - but with this hook, everyone (logged in or not) will have this button redirecting to the main home page.

that may or may not be a good thing for your situation (though might leave the user no obvious way to get to their portal home), so you might have to consider only redirecting the home button to your domain if the client is not logged in.

Link to comment
Share on other sites

Tried the below, and had placed in /includes/hooks
But didn't work either.

<?php

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

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

});

Edited by StarburstHosting
Link to comment
Share on other sites

  On 11/15/2020 at 2:03 PM, StarburstHosting said:

How would I do it just or non-clients, like you mentioned in the last paragraph?

Expand  

the way I would do it is...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	$client = Menu::context('client');
	if (is_null($client) && !is_null($primaryNavbar->getChild('Home'))) {
		$primaryNavbar->getChild('Home')->setURI('https://starbursthosting.com');
	}
});
Link to comment
Share on other sites

  On 11/15/2020 at 2:17 PM, brian! said:

the way I would do it is...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	$client = Menu::context('client');
	if (is_null($client) && !is_null($primaryNavbar->getChild('Home'))) {
		$primaryNavbar->getChild('Home')->setURI('https://starbursthosting.com');
	}
});
Expand  

Thank You very much for your help.

Just uploaded and is working. 🙂

Link to comment
Share on other sites

  • 2 years later...

thank you this thread helped me out too.

however i noticed that when a logged in user logs out, it takes the client to the whmcs home page still.

so, what code can i use to have the client go to the parent site in such a case aswell?

Link to comment
Share on other sites

  • 3 weeks later...

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