WordPress.org

Ready to get started?Download WordPress

Forums

Hide login form if logged in (3 posts)

  1. bujaman
    Member
    Posted 2 years ago #

    I am trying to hide the login form that I have added to my header when a user is logged in. Here is the code that I have so far, but it isn't working for some reason. My site is http://www.blindbidpro.com. Thanks in advance for any help!

    <div id="header-signup">
    	<div class="headerloginform">
    
    <?php
    if ( is_user_logged_in() ) {
       wp_loginout();
    } else {
    	<form name="loginform" id="loginform" action="http://www.blindbidpro.com/wp-login.php" method="post">
    		<div class="aligntop">
    		<input value="Username" class="input" type="text" size="20" tabindex="10" name="log" id="user_login" onfocus="if (this.value == 	'Username') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Username';}" /> </br><input name="rememberme" id="rememberme" value="forever" tabindex="90" type="checkbox"> Remember Me
    		</div>
    		<div class="aligntop">
    		<input value="Password" class="input" type="password" size="20" tabindex="20" name="pwd" id="user_pass" onfocus="if (this.value == 'Password') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Password';}" /></br><a href="http://www.blindbidpro.com/wp-login.php?action=lostpassword">Forgot your password?</a>
    		</div>
    		<div class="aligntop">
    		<input name="wp-submit" id="wp-submit" value="" tabindex="100" type="submit">
    		<input name="redirect_to" value="http://www.blindbidpro.com" type="hidden">
    		<input name="testcookie" value="1" type="hidden">
    		</div>
    		<div class="aligntop">
    		<a href="http://www.blindbidpro.com/wp-login.php?action=register" class="link1"></a>
    		</div>
    	</form>
      ;
    }
    ?>
    	</div>
    </div>
  2. Chandan Kumar
    Member
    Posted 2 years ago #

    Write it as:

    <?php if ( !is_user_logged_in() ) { ?>
       <form name="loginform" id="loginform" action="http://www.blindbidpro.com/wp-login.php" method="post">
    		<div class="aligntop">
    		<input value="Username" class="input" type="text" size="20" tabindex="10" name="log" id="user_login" onfocus="if (this.value == 	'Username') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Username';}" /> </br><input name="rememberme" id="rememberme" value="forever" tabindex="90" type="checkbox"> Remember Me
    		</div>
    		<div class="aligntop">
    		<input value="Password" class="input" type="password" size="20" tabindex="20" name="pwd" id="user_pass" onfocus="if (this.value == 'Password') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Password';}" /></br><a href="http://www.blindbidpro.com/wp-login.php?action=lostpassword">Forgot your password?</a>
    		</div>
    		<div class="aligntop">
    		<input name="wp-submit" id="wp-submit" value="" tabindex="100" type="submit">
    		<input name="redirect_to" value="http://www.blindbidpro.com" type="hidden">
    		<input name="testcookie" value="1" type="hidden">
    		</div>
    		<div class="aligntop">
    		<a href="http://www.blindbidpro.com/wp-login.php?action=register" class="link1"></a>
    		</div>
    	</form>
    <?php } else { ?>
    	// Log out code
    } ?>
  3. bujaman
    Member
    Posted 2 years ago #

    Thanks! I really appreciate the reply. I played around with it late last night and got this to work:

    <div id="header-signup">
    <?php global $user_ID; if( $user_ID ) : ?>
    <div class="headerloginform_nli">
    <?php wp_loginout();?> |
    <a href="#" onclick="window.open('http://www.blindbidpro.com/?s2member_profile=1', '_popup', 'width=600,height=400,left=100,screenX=100,top=100,screenY=100,location=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1'); return false;">Your Profile</a>
    </div>
    <?php else : ?>
    <div class="headerloginform">
    <form name="loginform" id="loginform" action="http://www.blindbidpro.com/wp-login.php" method="post">
    		<div class="aligntop">
    		<input value="Username" class="input" type="text" size="20" tabindex="1" name="log" id="user_login" onfocus="if (this.value == 	'Username') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Username';}" /> </br><input name="rememberme" id="rememberme" value="forever" tabindex="3" type="checkbox"> Remember Me
    		</div>
    		<div class="aligntop">
    		<input value="Password" class="input" type="password" size="20" tabindex="2" name="pwd" id="user_pass" onfocus="if (this.value == 'Password') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Password';}" /></br><a href="http://www.blindbidpro.com/wp-login.php?action=lostpassword" >Forgot your password?</a>
    		</div>
    		<div class="aligntop">
    
    		<input name="wp-submit" id="wp-submit" value="" tabindex="100" type="submit">
    		<input name="redirect_to" value="http://www.blindbidpro.com" type="hidden">
    		<input name="testcookie" value="1" type="hidden">
    		</div>
    		<div class="aligntop">
    		<a href="http://www.blindbidpro.com/wp-login.php?action=register" class="link1"></a>
    		</div>
    	</form>
    	</div>
    </div>
    
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic