function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
EIE50EIE50 

href re-direction according to user logged in or not

Hi,

 

I have a site's VF page in which i have an href attribute pointing towards an url. Without using apex, i want to check this condition in VF when user clicks on the href, If user is logged in send him to google.com else send him to yahoo.com. How can i do this?

 

Thanks.

bob_buzzardbob_buzzard

There's probably a few ways to do this.  One (slightly clunky) way that I've done it is to use the $User.UserName global variable and check for the name of the site in the string (as the "Guest" user has the name of the site as its username).

 

I've tended to use this for conditional rendering, but it work okay in javascript.