Blog > Website Design > WordPress Custom Login Box, A Members Section

Recently I was developing a client website in WordPress, where we needed to implement a custom login box for the website’s sidebar. What you see in the image above is an exact result of that integration with custom CSS is being applied.

WP Code

<!-- If User Is Logged In Display This -->

<?php if (is_user_logged_in()) { ?>

Welcome <strong><?php echo $user_identity ?></strong>.

<form name="loginform" id="loginform" action="<?php echo wp_logout_url(); ?>" method="post">

<input type="submit" name="wp-submit" id="wp-submit" value="LOG OUT" />
<a href="http://www.yourdomain.com/wp-admin/">EDIT YOUR PROFILE</a>

<input type="hidden" name="redirect_to" value="<?php bloginfo('url'); ?>" />
</form>

<!-- If User Is NOT Logged In Display This -->

<? } else { ?>

<form name="loginform" id="loginform" action="<?php bloginfo('url'); ?>/wp-login.php" method="post">

<label for="log">Username</label> <input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" /></p>
<label for="pwd">Password</label> <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></p>

<input type="submit" name="wp-submit" id="wp-submit" value="LOG IN" /> <input type="button" value="SIGNUP" onClick="parent.location='<?php bloginfo('url'); ?>/wp-login.php?action=register'" />

<a href="<?php bloginfo('url'); ?>/wp-login.php?action=lostpassword">Lost your password?</a>

<input type="hidden" name="redirect_to" value="<?php bloginfo('url'); ?>/members" />
<input type="hidden" name="testcookie" value="1" />
</form>

<? } ?>

Code Modifications

You can modify anything in the code. Just apply your CSS to make it look prettier.

Redirect The User After Login

This part of the code tells WordPress where to take the user after they logged in. The default is set to the domain root, but you can change it to any page. Example : a custom template like members.php, etc.

<!-- User Redirection -->

<input type="hidden" name="redirect_to" value="<?php bloginfo('url'); ?>" />

Have fun with the code.

Posted by : Dinusha | May 1, 2009

13 Responses to “WordPress Custom Login Box, A Members Section”

  1. Robbie Says:
    13

    Fantastic blog, very handy! Keep the good work up :)

  2. Lucretia Spetter Says:
    12

    it’s good to find a blog done by someone with similar views to mine. how do?

  3. Jared Says:
    11

    This would’ve been great had I seen it long ago before digging through the WP core to learn how to do it myself. I wrote a tutorial on how to create a login,register and password reset form, with jQuery tabs to show each form separately. And top it off with a quick how to on showing members only tab content. You can check it out here if you’re interested in learning how to make all these things that is.

    http://new2wp.com/pro/jquery-tabbed-login-register-forms/

  4. Club penguin Says:
    10

    Hello, I’m new to your site, I found it in Google. I’ve been browsing around your posts and I’d just like to say that I really like it :)

  5. Deon Mcdonell Says:
    9

    Great site. Can you provide more information on this cheers?

  6. Wordpress Theme Generator Says:
    8

    Great post your theme rocks! just subscribed. Wordpress is great I must say it is the most user friendly program to create themes. You can create your own themes with programs and save yourself a lot of money.

  7. club penguin Says:
    7

    Great post. Love it & your site is great too!

  8. Rosamond Linsley Says:
    6

    Hi that is a very fascinating view, It does give one food for thought, I am very delighted I stumbled on your blog, i was using Stumbleupon at the time, anyway i don’t want to drift on too much, but i would like to mention that I will be back when I have a little time to read your blog more exhaustively, Once again thanks for the post and please do keep up the good work,

  9. Tutyana Says:
    5

    Thanks a lot for the script. I really need it and it works excellent!

  10. juegos de casino virtual Says:
    4

    Really i am impressed from this post….the person who create this post he is a great human..thanks for shared this with us.i found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article.

  11. Honda Water Car Says:
    3

    You rock. World needs more souls like you.

  12. Dinusha Says:
    2

    Glad you like the posts. I will try to do my best to keep it up to date. Thank you very much for visits.

  13. Corey Says:
    1

    I found your blog on google, and read a few of your other posts. I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.

Leave a Reply

Name (required)

Mail (will not be published) (required)

Website

Blog Categories

Posts + Podcasts

Podcast Feeds

Design Portfolio

Design Services