Jump to content

Add login to wordpress header


oneofayykind

Recommended Posts

So here is what I'm trying to do. I'm using Wordpress. I have added a Login and Register link to my header along with an avatar box next to it like you would see next to someones comment. What I would like to have happen is after someone logs in that default avatar box update to their own avatar (if they have one or show the default avatar if they don't) and then not show the login and register links anymore and instead show a link to their profile.

Link to comment
https://forums.phpfreaks.com/topic/204492-add-login-to-wordpress-header/
Share on other sites

Use the following code to add a login form to your wordpress theme

 

<?php if (!(current_user_can('level_0'))){ ?>
<h2>Login</h2>
<form action="<?php echo get_option('home'); ?>/wp-login.php" method="post">
<input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="20" />
<input type="password" name="pwd" id="pwd" size="20" />
<input type="submit" name="submit" value="Send" class="button" />
    <p>
       <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label>
       <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
    </p>
</form>
<a href="<?php echo get_option('home'); ?>/wp-login.php?action=lostpassword">Recover password</a>
<?php } else { ?>
<h2>Logout</h2>
<a href="<?php echo wp_logout_url(urlencode($_SERVER['REQUEST_URI'])); ?>">logout</a><br />
<a href="http://XXX/wp-admin/">admin</a>
<?php }?>

 

Thanks

 

website development australia

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.