WordPress.org

Ready to get started?Download WordPress

Forums

horizontal login box (4 posts)

  1. Ruriko
    Member
    Posted 5 years ago #

    Anyone know how to make a horizontal login box?

  2. Eric Mann
    Member
    Posted 5 years ago #

    Yes!

    If you go to http://www.cmscareerxroads.com, you'll see a horizontal login box in the upper right corner of the screen. Here's the code that allowed me do put it there:

    <?php global $user_ID; ?>
    <?php get_currentuserinfo(); ?>
    <?php if(! $user_ID){ ?>
    	<div id="loginbar">
    	<form name="loginform" id="menulogin" action="<?php bloginfo('wpurl'); ?>/wp-login.php?redirect_to=/main" method="post">
    		<label><?php _e('username') ?> <input type="text" name="log" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" size="10" tabindex="1" /></label>
    		<label><?php _e('password') ?> <input type="password" name="pwd" value="" size="10" tabindex="2" /></label>
    		<?php do_action('login_form'); ?>
    		<input type="submit" name="wp-submit" value="<?php _e('log in'); ?>" tabindex="3" />
    		<input type="hidden" name="redirect_to" value="<?php echo attribute_escape($_SERVER['REQUEST_URI']); ?>main" />
    	</form>
    	</div>
    <?php } ?>

    The "loginbar" div gives you the ability to style things appropriately for your theme. I also recommend changing the "redirect-to=/main" line to whatever applies for your particular site. In this case, we're redirecting people to a particular landing page.

  3. Ruriko
    Member
    Posted 5 years ago #

    Once they are redirected to what ever page how can I want to put a welcome message with a logout link. How can I do that?

  4. Eric Mann
    Member
    Posted 5 years ago #

    Ruriko, that's actually even simpler. Just put your welcome message as you normally would, and give them a link that references:

    <a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=logout">Log Out</a>

    Anyone clicking on that link will be logged off and returned to the WordPress login screen. If you want them to be sent elsewhere, change it to the following:

    <a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=logout&redirect_to=/home">Log Out</a>

    Make sure to change /home to whatever page you want them to be redirected to.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.