ChetG
03-23-2010, 08:12 PM
Hello all!
I am working on a new site for a client, and I'm trying something I've never tried before. I am using Wordpress to make their life easier, and I'm using its is_user_logged_in() function.
Basically this is what I want to do:
<?php
if ( is_user_logged_in() ) {
Display Private Info;
}
else {
Display Log-In Form
};
?>
I am focusing on getting the log-in form working, and I can't figure out how to get more PHP to run in the else statement. It keeps throwing unexpected < errors.
Here is the problem piece:
<?php
if ( is_user_logged_in() ) {
echo 'Welcome, registered user!';
} else {
<?php
$blogurl = bloginfo('url');
$postlink = $_GET['redirect'];
?>
<link rel="stylesheet" href="<?=$blogurl ?>/wp-admin/css/login.css" type="text/css" />
<div id="login">
<form name="loginform" id="loginform" action="<?=$blogurl ?>/wp-login.php" method="post">
<p>
<label>Username<br />
<input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" /></label>
</p>
<p>
<label>Password<br />
<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
</p>
<p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> Remember Me</label></p>
<p class="submit">
<input type="submit" name="wp-submit" id="wp-submit" value="Log In" tabindex="100" />
<input type="hidden" name="redirect_to" value="<?=$postlink ?>#respond" />
<input type="hidden" name="testcookie" value="1" />
</p>
</form>
<p id="nav">
<a href="<?=$blogurl ?>/wp-login.php?action=lostpassword" title="Password Lost and Found">Lost your password?</a>
</p>
</div>
<p id="backtoblog"><a href="#" class="lbAction" rel="deactivate">Close</a></p>
<script type="text/javascript">
try{document.getElementById('user_login').focus();}catch(e){}
</script>
};
?>
I hope one of you geniuses out there are able to help out. Thanks in advance for all of your advice!
I am working on a new site for a client, and I'm trying something I've never tried before. I am using Wordpress to make their life easier, and I'm using its is_user_logged_in() function.
Basically this is what I want to do:
<?php
if ( is_user_logged_in() ) {
Display Private Info;
}
else {
Display Log-In Form
};
?>
I am focusing on getting the log-in form working, and I can't figure out how to get more PHP to run in the else statement. It keeps throwing unexpected < errors.
Here is the problem piece:
<?php
if ( is_user_logged_in() ) {
echo 'Welcome, registered user!';
} else {
<?php
$blogurl = bloginfo('url');
$postlink = $_GET['redirect'];
?>
<link rel="stylesheet" href="<?=$blogurl ?>/wp-admin/css/login.css" type="text/css" />
<div id="login">
<form name="loginform" id="loginform" action="<?=$blogurl ?>/wp-login.php" method="post">
<p>
<label>Username<br />
<input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" /></label>
</p>
<p>
<label>Password<br />
<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
</p>
<p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> Remember Me</label></p>
<p class="submit">
<input type="submit" name="wp-submit" id="wp-submit" value="Log In" tabindex="100" />
<input type="hidden" name="redirect_to" value="<?=$postlink ?>#respond" />
<input type="hidden" name="testcookie" value="1" />
</p>
</form>
<p id="nav">
<a href="<?=$blogurl ?>/wp-login.php?action=lostpassword" title="Password Lost and Found">Lost your password?</a>
</p>
</div>
<p id="backtoblog"><a href="#" class="lbAction" rel="deactivate">Close</a></p>
<script type="text/javascript">
try{document.getElementById('user_login').focus();}catch(e){}
</script>
};
?>
I hope one of you geniuses out there are able to help out. Thanks in advance for all of your advice!