rss

Using jQuery to liven up your WordPress login

23 Apr, 2008 Admin,jQuery

Image by: maistora

When I’m coding a project for a client, I always try make using the site as easy as possible. Whether it be using custom fields to automate the use of images in a post, or coding wp-admin pages to make the writing of posts & pages easier for them to do. Less is more… So in applying this principle, I’m going to show a really quick method of simplifying the clients login process using a jQuery lightbox.

Here’s a demo of what we’re going to do.

Just in case you’ve been coding in a box for the last 10 years, jQuery is a great JS library that has a number of nifty usages. One of its popular plugins is the ‘thickbox‘ and its what we’re going to use now to create a simple means of logging in for you/your clients.

Prepare your site

In your header.php file you need to include 3 files: jquery.js, thickbox.js and thickbox.css. Then upload the included loading.gif animation to your images folder. The includes for these files would look like this:

<script type="text/javascript" src="<? bloginfo('template_directory'); ?>/jquery-latest.pack.js"></script>
<script type="text/javascript" src="<? bloginfo('template_directory'); ?>/thickbox-compressed.js"></script>
<link rel="stylesheet" type="text/css" href="<? bloginfo('template_directory'); ?>/thickbox.css" media="screen" />

NOTE: call the jquery file before the thickbox.js file.

Then open your thickbox.js file and edit the path to your theme’s images folder. It’ll look something like this:

var tb_pathToImage = "/wp-content/themes/yourtheme/images/loadingAnimation.gif";

Ok, now your site is thickbox’d. Nice.

Make it happen

Of the many usages of the thickbox, the one we’re going to use now is the thickbox for Inline Content. In essence, you’re going to have your login form somewhere on your page (preferably in an element that is included on every page on your site like your sidebar) but its going to be hidden by an inline CSS style:

<div id="form" style="display:none;">

Somewhere else on your page, you’re going to have a link (like in your topnav) that when clicked, will open that hidden div/form in the thickbox. This link will have, instead of a URL as its href target, some magic thickbox commands that will summon your hidden login form. The link would be as follows:

<a href= "#TB_inline?height=200&width=200&inlineId=form" title="Login to the WP Guru site">Login</a>

What’s happening here is that the link is calling an inline div that’ll be displayed in a thickbox with the sizes specified and you’re identifying the inline div ID that will be called. Note that class=”thickbox” is critical to the thickbox’s successful usage.

The login form

The actual login form can be simplified down to its core elements so that you have nice neat code made up of only what you need. You can of course tweak this to be just what YOU need. The actual login form is found around line 378 in the wp-login.php file (v2.5).

<div id="form" style="display:none;">
 <form name="loginform" id="loginform" action="http://wpguru.co.za/wp-login.php" method="post"><input type="hidden" name="phpMyAdmin" value="01d7dd3a1764f33b9145cd20ad99db24" />
 <p>
 <label>Username<br />
 <input type="text" name="log" id="user_login" value="" size="20" tabindex="10" /></label>
 </p>
 <p>
 <label>Password<br />
 <input type="password" name="pwd" id="user_pass" value="" size="20" tabindex="20" /></label>
 </p>
 <?php do_action('login_form'); ?>
 <p><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> Remember Me</label></p>
 <p>
 <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Log In'); ?>" tabindex="100" />
 <input type="hidden" name="redirect_to" value="/" />
 <input type="hidden" name="testcookie" value="1" />
 </p>
 </form>
</div>

You can of course style up the div that contains your form with your site logo etc to make the whole login process seem even more bespoke.

TIP: You can set the overlay color of your jQuery thickbox (default set to 75% black) to match your site, in line #39 of your thickbox.css file.

80 Comments

  1. Hey, this is cool! I have done all these steps, though, and my thickbox is coming up just fine- but there is no login form in it. I’m a semi-new self-taught gal on this stuff and I’m not sure if there is something I have to do to the wp-login.php file in the main folder? It seems like that’s missing piece. (Sorry if this is a dumb question!)

  2. Nifty little trick. I’ve actually done some similar things for clients before, but found myself going the full mile and totally customizing the entire dashboard just to keep the user away from the whole BANG WORDPRESS appearance.

    I will give the jquery stuff a read – I’ve been coding since I was 7yrs old and now I think I might have been in the box, well at least according to you ;)

    Thanks for a interesting post,

    iMod.co.za

  3. Hi Viv! :) You need to duplicate the form FROM your wp-login.php page into your theme files and put it in the #DIV that you’re showing in your thickbox. So when the thickbox appears, it’ll display the login form.

    IE, the last code snippet in this article, the login form, must be inside your hidden DIV that you show inside your thickbox…

    There’s no need to touch your wp-login file :)

    Let me know if you come right?

  4. Hey Marky,

    Awesome.. luv it.. jquerys’ thick box is better scriptolicious etc.. much faster. Also another way is to use accordion.. ? (I can think of half a dozen ways to improve logins) :-) But that for next time. :-P

    Marek | Deenworks.com

  5. Awesome…you sir are a badass!! This what i was looking for all day! Thanks a million!

  6. Nice, only 1 thing, when i’m logged in i get a refresh to the homepage instead of the page i called the login function. Is there a way to work around this?

  7. Does anyone know if I can do this with Shadowbox?

    I have conflicts with other plugins and thickbox

  8. As far as I can tell, the Demo doesn’t work without JS, and that’s a serious issue. In case JS is disabled/unavailable, a simple html login form should open instead (AJAX best practices). Otherwise, you’re building something which won’t work in some cases…

  9. OMG!! I’d been looking for this all day! thank you!

  10. Is there a way to have the login link change to logout once you have logged in ?

  11. Nice write up…usually I never reply to these thing but this time I will,Thanks for the great info.

  12. Just make a plugin for noobs……. please

  13. Let me give you several examples: When you are sports fan you are united to that team. ,

  14. Thanks for your tutorial!! I’ve linked to you over in my blog at WPMU.org: http://wpmu.org/7-ways-to-spice-up-your-wordpress-login/ Just thought you might want to know that you’ve been featured. :)

  15. Thanks for making this. I took the principle and added it to Fancybox jquery since I was already using it.

  16. I face one problem in following your example. I have placed the files on server, linked them into header. Instead of hard coding the wp-login.php file, I included the form code in the sidebar as invisible(with div id=”form”). But when I click my link placed on navigation bar, nothing seems to happen. Please help me out.

  17. Excellent your ability as a copywriter are remarkable

  18. Рассылка на 4795 досок обьявлений а так же на 49000 закрытых форумов и о ваших сайтах и товарах сразу же узнают тысячи покупателей. Рассылка будет сделана в течении 30 минут после обращения. Предоставляем визуальнный отчет в режиме реального времени. Ценам за рассылку на доски всего 220 рублей. Наш тел. 89266853242 ICQ 568113539 rutop10@mail точка ru PS. Раскручиваем сайты,выводим в ТОР.

  19. Разбросакм рекламу о вашем сайте на 3700 дооск обьявлений и сайты быстро после обращения.Стоимость всего 220 рублей и о вас узнают миллионы покупателей.Рредоставляем отчет.Наш тел. 89266853242 ICQ 568113539 rutop10@mail точка ru PS.Раскручиваем и выводим в ТОР сайты

  20. Рассылка рекламы нк 4850 досок а так же на 49000 закрытых форумов и о ваших сайтах и товарах мгновенно узнают миллионы покупателей. Рассылка будет сделана в течении 15 минут после обращения. Предоставляем визуальный отчет в режиме раельного времени. Стоимость за рассылку на доски всего 240 рублей. Наш тел. 89266853242 ICQ 568113539 rutop10@mail точка ru PS. Раскручиваем сайты,выводим в ТОР.

  21. Рассылка рекламы на 4850 досок а так же на 43000 форумов и о ваших сайтах и товарах мгновенно узнают десятки тысяч покупателей. Рассылка будет сделана в течении 30 минут после обращения. Предостааляем визуальный отчет в режиме реального времени. Стоимость за рассылку на доски всего 210 рублей. Наш тел. 89266853242 ICQ 568113539 rutop10@mail точка ru PS. Раскручиваем сайты,выводим в ТОР.

  22. Рассылка оббьявлений на 5000 досок а так же на 44000 закрытых формуов и о ваших услугах сразу же узнают десятки тысяч покупателей. Рассылка будет сделана в течении 10 минут после обращения. Предоставляем визуальный отчет в режиме реального времени. Цена за рассылку на доски всего 250 рублей. Наш тел. 89266853242 ICQ 568113539 rutop10@mail точка ru PS. Раскручиваем сайты,выводим в ТОР.

  23. Рассылка рекламы на 485 досок а так же на 40000 закрытых форумов и о ваших пердложениях мгновенно узнают десятки тысяч покупателей. Рассылка будет сделана в течении 15 минут после обиащения. Предоставляем виуальный отчет в режиме реального времени. Стоимость за рассылку на доски всего 240 рублей. Наш тел. 89266853242 ICQ 568113539 rutop10@mail (точка) ru PS. Раскручиваем сайты,выводим в ТОР.

  24. Рассылка обьявлений на 4800 досок обьявлений а так же на 47000 закрытых форумов и о ваших товарах мгновенно узнают десятки тысяч покупателей. Рассылка будет сделана в течении 25 минут после обращения. Предоставляем визуальный отчет в режиме реального времени. Цена за рассылку на доски всего 220 рублей. Наш тел. 89266853242 ICQ 568113539 rutop10@mail (точка) ru PS. Раскручиваем сайты,выводим в ТОР.

  25. [b]Здраствуйте!

    Я являюсь представителем молодой, динамично развивающейся, соц. сети.
    У нас есть деловое взаимовыгодное предложение к Вам. Пожалуйста, свяжитесь со мной любым, удобным для Вас способом:

    ICQ 598502427
    Skype: lan_stranger
    bilalovm@gmail.com
    C ув. Марат Билалов[/b]

  26. it is true.

  27. I am wondering if you can take out login and make seesmic in there .. like http://www.deafvideo.tv .. click video comment in there and see how it appear on thickbox .. that one i want .. can you do that for me ?

  28. interesting article, is the first entered in this site and will not be the last
    Greetings

  29. Лучшие мастера столицы немедленно в течении 30 минут после звонка приедут и отремонтируют холодильники и морозильники любых марок.Выезд бесплатный.Цены на ремонт очень низкие.Наш сайт: http://www.gorodservis.ru Ремонт холодильников дизайном

  30. Thanks a bunch for this I was looking for something like this all day. The next thing I’m going to teach myself is as you said “coding wp-admin pages to make the writing of posts & pages easier for clients” I’ll see if I can find anything on this topic on your site! Cheers.

  31. Грамотный пост

  32. What a nice post. I absolutely admire your Page about Stethoskop und Belkin Router! http://goe.bplaced.net/?path=guestbook Stethoskop und Belkin Router

  33. Neat blog! Is your theme custom made or did you download it from somewhere? A design like yours with a few simple tweeks would really make my blog shine. Please let me know where you got your theme. With thanks

  34. سلام
    من متاسفانه انگليسيم خوب نيست
    لطفاً اگر امكان دارد فايل jquery اين آموزش را براي من بفرستيد!
    sabzinezhad@gmail.com
    متشكرم

  35. Хочется уточнить, а данный сайт ползуется спросом? Только зарегился, вот интересно. Спасибо!

  36. What i do not realize is actually how you’re not really much more well-liked than you might be right now. You are so intelligent. You realize therefore considerably relating to this subject, made me personally consider it from a lot of varied angles. Its like women and men aren’t fascinated unless it’s one thing to do with Lady gaga! Your own stuffs nice. Always maintain it up!

  37. Awesome information. Thanks! I’m also hoping to get a little assistance with changing the background of my in-line login form. I’ve been able to change the form background but not the entire content… help please.

  38. very nice info friend…

  39. Hi everyone, I’m having some trouble with my log in form. The thickbox works fine the issues is the submit button, for some reason the button does not work. You can see what I’m talking about by clicking http://yellow6design.com/2fish/checkered/. Click Log in in the upper right corner.

    Thanks in advance,
    Rey

Trackbacks

  1. Today In WordPress :: WordPress Upgrades
  2. 26 Nisan web’den seçme haberler » Tekil Yazı » Fatih Hayrioğlu'nun not defteri
  3. Güzel bir Wordpress giriş paneli » Bilgisayar Hocası
  4. [ fatih hayrioğlu ]26 Nisan Seçmeler « CSS Arşiv
  5. Local company spams top SA bloggers! | iMod
  6. Free WordPress and jQuery: 25+ Useful Plugins & Tutorials | designersmantra.com
  7. All my bookmarks ever | Daniel John Gayle
  8. The Power of WordPress and jQuery: 25+ Useful Plugins & Tutorials | Quest For News, A TUTORIAL Base
  9. 15 Plugins to Unleash the Invincible Power of jQuery and Wordpress
  10. Today in WordPress world - 20/07 | Links | WereWP
  11. 30 Tutorials Combining Both Wordpress and jQuery : Speckyboy Design Magazine
  12. 30 Tutorials Combining Both Wordpress and jQuery | huibit05.com
  13. 13 Plugins para soltar o poder do jQuery no Wordpress « Xigli
  14. 30 Tutorials Combining Both Wordpress and jQuery | .::tek3D Weblog::.
  15. 35 Stylish And Modern Wordpress Plugins Using jQuery UI | Graphic and Web Design Blog - Inspiration, Resources and Tools
  16. 35 elegantes y modernos Plugins para Wordpress usando jQuery UI | Don Pipa.com, web oficial
  17. 35 Stylish And Modern Wordpress Plugins Using jQuery UI | pc-aras
  18. 30 Tutorials for Using JQuery in Wordpress | oOrch Blog
  19. 35 Stylish And Modern Wordpress Plugins Using jQuery UI - Programming Blog
  20. 40+ Quite Useful Wordpress Plugins using jQuery | tripwire magazine
  21. Fesches Ajax Login Formular | Medienbeckerei Blog
  22. Lorelei Web Design » 75 Best Wordpress Plugins That Make Bloggers Lives Easier
  23. 35 Stylish and Modern Wordpress Plugins using jQuery UI | AlexVerse
  24. The Power of WordPress and jQuery: 25+ Useful Plugins & Tutorials | HOSTERWARE UK. Tel 02081337636
  25. Представляю Вашему вниманию - jquery плагины для wordpress | Okinak
  26. 30 tutorial para utilizar jQuery en nuestro Wordpress | code
  27. 35 Stylish And Modern Wordpress Plugins Using jQuery UI » The Nowhere News
  28. 31 Great Wordpress jQuery Resources | Pingable :: Everything Wordpress
  29. 31 Great WordPress jQuery Resources | The Designer's Pod
  30. 35 Stylish And Modern WordPress Plugins Using jQuery UI « DownGraf – Your Graphic World
  31. 20+ jQuery and Wordpress Tutorials – A Match Made in Heaven
  32. WordPress and Jquery Plugins | www.eqloud.com
  33. 20 Stylish WordPress Plugins Using jQuery UI
  34. 35 Stylish And Modern WordPress Plugins Using jQuery UI « Downgraf – Design weblog for designers
  35. Top jQuery WordPress Tutorials and Plugins - DesignModo
  36. 30 Tutorials Combining Both WordPress and jQuery | a place to share, bookmarks, resources, css, jquery, photoshop, design, inspiration
  37. Top Wordpress jQuery Plugins-Nihad Nagi
  38. 16 Useful jQuery Tutorials to Enhance your WordPress Site

Leave a Reply

About The WordPress Guru

Over the last 4 or 5 years, I’ve been digging into the Wonders of WordPress. From the days when the Classic theme was the shizz until now, WordPress has gone from strength to strength both as the blogging platform of choice for many big players and as a CMS with...

Learn more »