SharePoint 2007 Portal Site Hidden Login

In an on-going effort the create SharePoint template pages we have made a nice piece of code that allows us to hide the login button of the SharePoint Portal site unless users add a specific variable to the URL or unless they are logged in:

SPUser currentUser = SPContext.Current.Web.CurrentUser;
string DisplayLogin = Request[“login”];
if ((currentUser != null) || (DisplayLogin != null)) {
<table cellpadding=”0″ cellspacing=”0″>
<tr style=”height:0px”>
<wssuc:DesignModeConsole id=”IdDesignModeConsole” runat=”server”/>
<!–Authentication for Authors only–>
<wssuc:Welcome id=”explitLogout” runat=”server”/>
<PublishingSiteAction:SiteActionMenu runat=”server”/>
<% } %>

The first part we use to check for a username. If none is found we can presume there is no user logged in. The second part with the DisplayLogin variable is used to check the URL for an add-on like

Not that in this script it doesn’t really matter what value is set to login as long as it is not NULL,

Leave a Reply

Your email address will not be published. Required fields are marked *