Jump to content
zitu4life

Hook that auto replace LOGO url to clientarea.php

Recommended Posts

Hello there

I am looking a hook that will auto detect if client is logging in on client area, to override LOGO url to clientarea.php

Usually if we click on logo it will take us to index.php page, but I would like it to forward to clientarea.php if client is logged in. So every time I click on logo it will forward to picture below page.

image.thumb.png.b455cda44e2ed515fc48e6cc70f90ee1.png

Share this post


Link to post
Share on other sites
14 hours ago, zitu4life said:

I am looking a hook that will auto detect if client is logging in on client area, to override LOGO url to clientarea.php

but in your case, you should just need to wrap the return with an IF statement to check whether the client is logged in...

<?php

# Change Logo URL Hook
# Written by brian!

function change_logo_url_hook($vars) {
	
	$client = Menu::context('client');
	if ($client) {
		return "<script>
$(function(){
   $('a.logo').attr({href:'clientarea.php',target:'_blank'});
});
</script>";
	}
}
add_hook("ClientAreaFooterOutput", 1, "change_logo_url_hook");

optionally, it's also going to open in a new window/tab - if you don't want that, then just remove the ,target:'_blank' part.

Share this post


Link to post
Share on other sites

The above code will not work when using search engine friendly urls, for example if you're on the domain renewals page the page url would be:

yoursite.com/cart/domain/renew

The above code would cause the logo to link to the following url resulting in a 404 error:

yoursite.com/cart/domain/clientarea.php

 

You can overcome this be utilising the {$webroot} variable. I've updated the code above to include  this, as well as function for both the six and twenty-one theme:

 

<?php

# Change Logo URL Hook
# Written by brian!

function change_logo_url_hook($vars) {
	
	$client = Menu::context('client');
	if ($client) {
		return "<script>
$(function(){
   $('a.logo').attr({href:'{$webroot}/clientarea.php',target:'_blank'});
   $('a.navbar-brand').attr({href:'{$webroot}/clientarea.php',target:'_blank'});
});
</script>";
	}
}
add_hook("ClientAreaFooterOutput", 1, "change_logo_url_hook");

 

 

Share this post


Link to post
Share on other sites
51 minutes ago, Impressive Themes said:

You can overcome this be utilising the {$webroot} variable.

not in the way you've done it - it wouldn't work.

<?php

# Change Logo URL Hook
# Written by brian!

function change_logo_url_hook($vars) {
	
	$client = Menu::context('client');
	if ($client) {
		return "<script>
$(function(){
   $('a.logo').attr({href:'".$vars['WEB_ROOT']."/clientarea.php',target:'_blank'});
   $('a.navbar-brand').attr({href:'".$vars['WEB_ROOT']."/clientarea.php',target:'_blank'});
});
</script>";
	}
}
add_hook("ClientAreaFooterOutput", 1, "change_logo_url_hook");
1 hour ago, Impressive Themes said:

as well as function for both the six and twenty-one theme:

in practice, you should probably detect which theme is being used and only return the applicable CSS.

Share this post


Link to post
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