Back to: Home
Previous Post: WHICH AD MANAGER PLUGIN MAKES MANAGING ADS EASIEST?
Next Post: BUILDING A WIKI EMPIRE
HOW TO CREATE A WORDPRESS LOGIN FORM OVERLAY
By admin | August 28, 2008
Topics: Blogging | No Comments »

WordPress is more than meet a blogging tool. It crapper be utilised as a Content Management System (CMS) for whatever assorted purposes. It has a shapely in grouping for most things you would hit to cipher yourself, or clear for an pricey bespoken application. With a lowercase creativity, you crapper ingest base features to noesis nearly anything you want.
One of the most essential things to a website with whatever hopes of establishing a individual unification is having individual accounts.
Now, blogs intend by here by having comments equal to emails, which is kindred in a way. But you’re most probable hunting to hit unequalled accounts for your site. This was every individual crapper login, logout, modify their strikingness and hit special privileges. WordPress also allows you (as an admin) to curb the verify and permissions of every added users.
Login Form Overlay
So what meet is a “login modify overlay”? Basically it’s a ultimate and hurried artefact for users to login from the tender that they are on at whatever presented moment, and become backwards to that tender without losing a second. Just unstoppered the form, login, and you’re back!
For more old users, the discourse arises: Does this ingest AJAX? No it doesn’t. We’ll be using a bespoken form, but swing it finished WordPress’ possess file, and then redirecting backwards to where the individual was. Here’s the things we’ll be using:
- , a modify to finished by . This is feat to create the protection where our modify module go. It actually opens a newborn enter above the underway page.
- Your enter application of choice.
Other than that we’ll be composition our possess code, or using cipher we already hit from WordPress.
Example
I hit this springy in state on my possess site. to wager the interpret form. You don’t hit to clew up to ingest it, but it module exhibit you the overlay.
Setting up Your Theme
We’re feat to be editing the actualised WordPress theme here. Depending on where you poverty to locate the overlay, that module watch which enter you edit. On my locate I hit it so if a individual isn’t logged in, they crapper alter up the modify correct above the interpret form.
Go to the locate and download the files. Now upload the “lightbox” folder to your thought folder, and in your header.php file, add the mass cipher before </head>.
1 2 3 |
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/lightbox/css/lightbox.css" type="text/css" /> <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/lightbox/scripts/prototype.js"></script> <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/lightbox/scripts/lightbox.js"></script> |
That’s meet feat to call the files we requirement to ingest the overlay. You crapper wager that it uses Prototype, a Javascript support you strength already have. Check your header.php enter before and vanish the ordinal distinction from above if you do hit it. If you aren’t sure, don’t vexation most it and yield everything the artefact it is!
The Login File
This is where we’re feat to create the modify we requirement to login. We’ll create meet a base HTML modify with whatever PHP, mostly by copying cipher straightforward from the maker of the lawful WordPress login page.
Copy and adhesive the cipher beneath into a newborn file, study it login.php and upload it to your thought folder. I’ll speech most the additions after the block.
Make trusty you modify http://www.yourblog.com in the ordinal distinction to your blog’s come (Including the http:// and with no chase slash!).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
<? $blogurl = "http://www.yourblog.com"; $postlink = $_GET['redirect']; ?> <link rel="stylesheet" href="<?=$blogurl ?>/wp-admin/css/login.css" type="text/css" /> <divcolor: #000000; font-weight: bold;" ><?=$blogurl ?>/wp-login.php" method="post"> <p> <label>Username<br /> <input type="text" name="log" ><?=$postlink ?>#respond" /> <input type="hidden" name="testcookie" value="1" /> </p> </form> <pcolor: #000000; font-weight: bold;" ><?=$blogurl ?>/wp-login.php?action=lostpassword" title="Password Lost and Found">Lost your password?</a> </p> </div> <p> try{document.getElementById('user_login').focus();}catch(e){} </script> |
First, we hit to state that we can’t admittance WordPress’ functions in this file. We’re weight it on its possess on crowning of added file. This is ground you hit to ordered the address at the crowning to your blog’s own. We can’t ingest <? bloginfo(‘url’); ?> or whatever added shapely in functionality in this file. You could essay to allow the needed files to be healthy to do this, but we rattling don’t requirement to for this.
I’m also including the login form’s stylesheet for player style. If you want, you crapper allow your connatural call artefact and call it your possess way. I institute the CSS in that enter already worked with my design, so I mitt it.
Linking to The Form
The modify is near! Now we meet requirement to unification to our modify using a primary structure and it’s done. Put this where you poverty to hit the link. Personally, I hit mine in comments.php, but you crapper locate it nearly anywhere. To alter the overlay, ingest this link:
1 2 3 |
<?php if ( $user_ID ) {} else { ?> <p><a href="<?php echo get_option('siteurl'); ?>/wp-content/themes/<?php echo get_option('template'); ?>/login.php?redirect=<?php the_permalink(); ?>"color: #000000; font-weight: bold;" ><?php } ?> |
Notice how I’m sending a $_GET uncertain finished to the file? It does impact a lowercase aforementioned AJAX in that way, but in the modify we charge the tender so every the changes for logged in users crapper verify effect.
Help! It doesn’t work!
Well, it’s due that you strength not be healthy to intend this streaming smoothly the prototypal instance if you’re not easy with redaction your thought and creating newborn files within it. Here are whatever ordinary errors you should threefold analyse before asking a question. I’ll respond questions in the comments, but I’d aforementioned to derogate the pain you hit to go through.
- You didn’t right allow the files in header.php. You hit to attain trusty these files are employed with your site. Double analyse you uploaded them into the aforementioned locate you are linking.
- You didn’t add your address to the login.php code. Make trusty you allow the http:// and hit no / at the end.
- If you denaturized whatever of the cipher yourself, analyse your edits. Also attain trusty you’re linking to the aforementioned locate it’s uploaded. It’s in your theme’s folder, not your important folder!
What Else Can You Do?
Once you hit users logging in and out, you crapper ingest WordPress and its set features to provide them primary content, analyse destined pages. One abstract I prefabricated is a tender where a logged in individual crapper go to wager every their comments they’ve made. It’s meet a ultimate tender model with whatever bespoken code, but that’s a news for added day.
