Wordpress Login Form Overlay

Author: Zeeshan

login-overlay1

WordPress is more than just a blogging tool. It can be used as a Content Management System (CMS) for many different purposes. It has a built in system for most things you would have to code yourself, or pay for an expensive custom application. With a little creativity, you can use basic features to power almost anything you want.

One of the most important things to a website with any hopes of establishing a user connection is having user accounts.

Now, blogs get by here by having comments tied to emails, which is similar in a way. But you’re most likely looking to have unique accounts for your site. This was every user can login, logout, edit their profile and have special privileges. WordPress also allows you (as an admin) to control the level and permissions of all other users.

Login Form Overlay

So what exactly is a “login form overlay”? Basically it’s a simple and quick way for users to login from the page that they are on at any given moment, and come back to that page without losing a second. Just open the form, login, and you’re back!

For more experienced users, the question arises: Does this use AJAX? No it doesn’t. We’ll be using a custom form, but putting it through WordPress’ own file, and then redirecting back to where the user was. Here’s the things we’ll be using:

  • Lightbox Gone Wild, a modification to LightboxJS done by ParticleTree. This is going to create the overlay where our form will go. It actually opens a new file above the current page.
  • Your file editor of choice.

Other than that we’ll be writing our own code, or using code we already have from WordPress.

Example

I have this live in action on my own site. Click here to see the comment form. You don’t have to sign up to use it, but it will show you the overlay.

Setting up Your Theme

We’re going to be editing the actual WordPress theme here. Depending on where you want to put the overlay, that will determine which file you edit. On my site I have it so if a user isn’t logged in, they can bring up the form right above the comment form.

Go to the Lightbox Gone Wild site and download the files. Now upload the “lightbox” folder to your theme folder, and in your header.php file, add the following code before .

/lightbox/css/lightbox.css" type="text/css" />


That’s just going to call the files we need to use the overlay. You can see that it uses Prototype, a Javascript framework you might already have. Check your header.php file before and remove the second line from above if you do have it. If you aren’t sure, don’t worry about it and leave everything the way it is!

The Login File

This is where we’re going to create the form we need to login. We’ll create just a basic HTML form with some PHP, mostly by copying code straight from the source of the regular WordPress login page.

Copy and paste the code below into a new file, name it login.php and upload it to your theme folder. I’ll talk about the additions after the block.

Make sure you change http://www.yourblog.com in the second line to your blog’s address (Including the http:// and with no trailing slash!).

<? $blogurl ="http://www.yourblog.com"; $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" 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>
	<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="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="#" rel="deactivate">Close</a></p>
 
<script type="text/javascript">
try{document.getElementById('user_login').focus();}catch(e){}
</script>

First, we have to note that we can’t access WordPress’ functions in this file. We’re loading it on its own on top of another file. This is why you have to set the URL at the top to your blog’s own. We can’t use or any other built in functionality in this file. You could try to include the necessary files to be able to do this, but we really don’t need to for this.

I’m also including the login form’s stylesheet for extra style. If you want, you can include your normal style sheet and style it your own way. I found the CSS in that file already worked with my design, so I left it.

Linking to The Form

The end is near! Now we just need to link to our form using a special syntax and it’s done. Put this where you want to have the link. Personally, I have mine in comments.php, but you can put it almost anywhere. To activate the overlay, use this link:

/wp-content/themes//login.php?redirect=" class="lbOn" title="Log in">Login &raquo;

Notice how I’m sending a $_GET variable through to the file? It does work a little like AJAX in that way, but in the end we reload the page so all the changes for logged in users can take effect.

Help! It doesn’t work!

Well, it’s expected that you might not be able to get this running smoothly the first time if you’re not comfortable with editing your theme and creating new files within it. Here are some common errors you should double check before asking a question. I’ll answer questions in the comments, but I’d like to minimize the trouble you have to go through.

  • You didn’t properly include the files in header.php. You have to make sure these files are working with your site. Double check you uploaded them into the same place you are linking.
  • You didn’t add your URL to the login.php code. Make sure you include the http:// and have no / at the end.
  • If you changed any of the code yourself, check your edits. Also make sure you’re linking to the same place it’s uploaded. It’s in your theme’s folder, not your main folder!

What Else Can You Do?

Once you have users logging in and out, you can use WordPress and its core features to give them special content, view certain pages. One thing I made is a page where a logged in user can go to see all their comments they’ve made. It’s just a simple page template with some custom code, but that’s a story for another day.

  • Share/Bookmark
blog comments powered by Disqus
xeex91009 farm for sale 37920 modern medieval sconces commercial new zealand vietnam nominal roll shrimp the very large telescope kaspersky updates american stock exchange chairman morse symptoms of guillain barr the black stork the documentary software for managing online auctions radko southwestern university cebu memo school board not pay fee signs of a fast metabolism corn mazes of nova scotia tina grabar roseburg schools roseburg oregon staff directory what state suggested the connecticut compromise superhero sketches evey sweet sunrise masala kolkata makeup course video bride takes off dress gown instructional strategies for speech impaired students hamburger weiss attorneys buffalo car sun protectors variety mp3 players high lifter tires family friendly resorts in puerto vallarta harrogate hotels green red placemats cooper discovery ht tires thoracic surgeon job milian sanders sails lymington couer d alene silver stock images head shots linda reginato rn vitamins in broccoli gotham watch boerne stage saddlery san antonio texas heredity and osteoarthritis pictures of a hobbit ferreira idea encryption algorithm 5 gallon plastic pail dimensions tank deaths yorktown naval virginia topical pain care market forecast care homes middlesbrough song cara mia hog rock cate twids oklahoma villas in puerta plata dominican republic saskatchewan association of teachers of french drawings of tigger 5 cylinder chevy nigerian stockbrokers cool hand poker simplex go karts sell maple leaf coin type of bait for channel catfish helpdesk metrics 90210 ayurveda center atlanta georgia showtimes for the dungeon general boch roy e butler arlington cemetary wood stove bellows katona hoodview motorsports supercharged prowler jeffree star wallpapers free articles differentiated education urethane rod stock deja vu clubs mural glass rosie hawkes and opp kill eze primer paint penis igloo and carnival feedom ship diagrams la quinta inn lax rock crawler xtreme center caps evaporative cooler for car pikeville ky albany ny advertiser mhu-83 loader weapon personel sites full free trials free cpt coding for infusions artistic ceiling fans cheyenne morrison zippered top stub checkbook wallet disassembly procedures for nokia 7370 wood inlay art spengler manor condos phoenix friedman zeise optical lenses seo workshops in los angeles concrete shortage conspiracy christian oliva dorothea lange arthur rothstein berkey do not smudge pedicure seks f-350 madeline hunter sample math lesson plans rocky prohunter parka the game of payday shipman nitto neo gen burden falls safest antidepressant in liver disease graco nautilus install vip health spa anderson rickman allergic to yeast flakes loosing season at kentucky basketball 3400 universities joann magnuson stan shafer abc labs o henry critiques poverty bread soup attached garage upstairs bedromm kurt vonnegut short stories playtex girdles stories casting calls for ordinary people line replaceable modules car ownership by decade chairs glider rockers swivel gliders coleccion escenas roberto malone adm roughead rent dozer tacoma blackmarket college degree killed 100 million people andrew fitzgerald dairy id typing eraser sourcing part time torrington ct dr powell crosley venice florida peice allure vinyl wood strips the conscious child d bahn amsterdam frankfurt 2001 diagram of lincon town motor xplod emerson humidifier cleaning procedures florida dogwood tree 18th 2002 for explorer hatch cargo door indian spinach and cheese bermuda water temperature snorkel determine right side of garter stitch sliding pocket windows buffalo wings washington st jamestown ny low emission vehicles list federal qualifying australia and oceania love is cartoons by kim casali como saber si alguien miente 60 spoke sportster wheels lesson plans for contractions the marrying of joe rees beethoven streaming radio numbness on big toes memorex 300 cd labels online gingerbread ways to relieve gas hilltop mn white pages richfield ohio gerry walin dr husted kingston ny margaret a bury maryland paginas para descargar peliculas dvdr pl capital llc etna high school easy to learn palm readings bg bookstore freemasons feat bailey tzuke ultra soft chenille yarn can stainless steel mop sink leann wheeler atlanta part no 12606 hooker goodwill overlea toronto projected euro futures stop sweaty armpits download latest aim messanger southern oregon property managers legacy soundtrack merrill jenson hallowee asylum madoff hite richard nixon resigns schulte wu-ftp change listening port cupcake tote bag cure for stomach ulcers st james seton viola a dunham kenyon ways to prevent deforestation yarn braiding nfl post season shedule examples of terminal illness sate of emergency cheats tunstall feline weak hind legs chicas bonitas desnudas michel georges paintings atomic fart ornamental woodcarving by johan amrud diverticulosis in transverse colon lice and dogs wyndam la cascada san antonio texas honda cm185t twinstar carburetor overflow hose recepies of arabic sweets cooper sst discover tires hitachi 42 in full hd television lozano coheed and cambria analysis dubuque iowa apartments valves for hydraulic roller cam application hazing in wrestling jim davis jacksonville jaguars cheddar cheese powder gomes leading edge warrenton va jack miller clarksville tennessee red young amphibian bergeron timothy connelly poetry paul bernardo and karla homolka soul feast marjorie thompson electronics xpress unitrin business insurance miguel diaz low sodium baking powder and featherweight homerun arp independent school district beau monde event planning ley lines in north east england the palm lv fireworks shipping boxes sanitas sem 40 instructions extended stay deluxe san rafael quads 4 sale msd coil kit accord hare krishna music serial killer richard kuklinski book 68 vette symbian file system type badger manufacturing barbra streisand shall we dance vx8300 calcutta pom marketing services grinder barnabas replace shocks 2004 malibu noisy jamaica as an emerging market knots mph conversion factor hostels granada nicaragua online battlefront siphon tube flows cabot san lucas pablo pacifica characteristics of a philosopher rush limbaugh phone physique atomique model robert bullard against john locklear prada fragrances yoga point voip solutions voip services voip reseller steamed haricots verts recipe with vinegar ice hair dressers in cwmbran require once phpsuexec problem scotland beheading 13 lew aerospace peyote sound system community asphalt paving lake circle drive fallbrook kunis colour palm emulator is beef slaughter cruel stripping moraine lake in alberta canada configuring cipher suites with tomcat 6 internet service fees deductible business expense esquema de uma celula procariotica free support our troops bracelet girls knickers bloomers directoire knickers bryson marine the haunted palace individuals technology challenges and franchise sti idaho panametrics epoch 4 barefoot properties catamaran travel to france hpi nitro engine 15 ecko manufactuing roman mythology apollo puff pastry appetizers bj zip code watertown ny wanda eddings sanford north carolina types iv slap lesions max baer jr woman shoots herself deepest underwater escape ww2 shells restaruant bradenton fl flats to rent maidstone connell buy idromeccanica italiana hydraulic breakers bermuda religons hager marc baptiste pictures pointer bushing ut transfer gpa requirements paquin bynes hdmi to usb for ps3 finance companys for auto dealers technine hoodies omron walking stle 1 tonka 41250 parts microsoft word freeware armageddon belching session gone seriously wrong honeywell ada ozawa wix filtration products europe phil chaney graphics indian fashion industry season hamas syndrome gift of the keepers alla stock secured loans lonesome road archery notre dame colledge of ohio dixieland taxidermy bronte run purchase live crayfish pensacola florida resturaunts marriage workshops westerville ohio sun chaser boats used futaba 2.4 fassst system hobbes innovations crohns and pain durning intercouse terri mccarty potted plants too much nitrogen airport shuttle seatac washington ce markings on eyewear weathering the storm of ibiza pics fido collection