WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: AJAX Login] al_template.php for wordpress 2.7 (7 posts)

  1. HappyApple
    Member
    Posted 5 years ago #

    With help from here. I have created an al_template that is compatible with wordpress 2.7 for AJAX Login. :D

    This template will say "Logged in as 'you username here' " when you are logged in. I also made it so the username is a link to the dashboard. that way I could get rid the the meta widget. Logging out will take redirect you to the page you were last visiting.

    To install, replace all code in "al_template.php" in "wp-content/plugins/ajax_login" with the coding below,
    or save the coding below as "al_template.php" and place it in your current theme's folder.

    You may need to edit this in order to make it match your theme. (I tested it with wordpress's classic and default theme and they worked. But as we know not all themes work the same. ;) )

    If you are using a Luckytheme.com theme. then all you should need to do is rename all "<h2></h2>" tags to "<h1></h1>"

    Hope this works for ya! :D

    Credit goes to Jonas Einarsson for making AJAX Login,
    and forum members Branch and Infected for finding 2.7 compatible logout code.

    <?php  
    
    /**********************   
    
    This is the default template for AJAXLOGIN.   
    
    Please do make a copy and put in your theme directory.   
    
    Elements which always must exist:
     - The forms al_registerForm, al_loginForm and al_lostPassword
     - The message spans al_registerMessage, al_loginMessage and al_lostPasswordMessage   
    
    Elements that must exist for the al_show****()-functions to work (recommended!)
    - al_loading
    - al_login
    - al_register
    - al_lostPassword   
    
    Just follow the format of the original al_template.php and you should be safe.  
    
     I know that the original does not conform to XHTML validation because of the <style>-tag. Just copy the styles you are using to your own CSS and you'll validate just fine.   
    
    The surrounding <li> are only there for widget compability.  
    
    ***********************/
    ?>   
    
    <?php
    global $user_ID, $user_identity;
     get_currentuserinfo();
    if (!$user_ID) {     
    
    /*******   This part is drawn when user is NOT logged in.   *******/  
    
    ?> 
    
    <style type="text/css">
    .al_nodisplay { 	display: none; }
    #al_loading, #al_register, #al_lostPassword { 	height: 175px; }
    #al_loginMessage, #al_registerMessage, #al_lostPasswordMessage {  }
    #al_loadingImage { 	margin-top: 35px; }
    #al_login2 { margin-left: 20px; }
    </style>  
    
    <div id="al_loading" class="al_nodisplay">
    <div class="title"><h2>Loading...</h2>
    </div>
    <div style="height: 100%; text-align:center;">
    <img id="al_loadingImage" alt="Loading..." src="<?php bloginfo( 'wpurl' ); ?>/wp-content/plugins/ajax-login/al_loading.gif"/>
    </div>
    </div>
    
    <div id="al_login">
    <div class="title"> <h2>Login</h2></div> <div id="al_login2">
    <form name="al_loginForm" onsubmit="return false;" id="al_loginForm" action="#" method="post"> 	<label><?php _e('User') ?>:
    <input onkeypress="return al_loginOnEnter(event);" type="text" name="log" value="" size="20" tabindex="7" /></label>     <label><?php _e('Password') ?>:
    <input onkeypress="return al_loginOnEnter(event);" type="password" name="pwd" value="" size="20" tabindex="8" /></label>
    <label><input type="checkbox" name="rememberme" value="forever" tabindex="9" /> <?php _e("Remember me"); ?></label>
    <input type="button" name="submit" value="<?php _e('Login'); ?> &raquo;" tabindex="10" onclick="al_login();"/>     <span id="al_loginMessage"></span>
    <a href="javascript:al_showRegister();">Register</a> | <a href="javascript:al_showLostPassword();">Lost password?</a>
         </form> </div> </div>  
    
    <div id="al_register" class="al_nodisplay">
    <div class="title"><h2>Register</h2>
    </div>
    <div id="al_login2">
        <form name="al_registerForm" onsubmit="return false;" id="al_registerForm" action="#" method="post">
    	<label><?php _e('User') ?>:<input onkeypress="return al_registerOnEnter(event);" type="text" name="user_login" value="" size="20" tabindex="7" /></label>
        <label><?php _e('E-mail') ?>: <input onkeypress="return al_registerOnEnter(event);" type="text" name="user_email" value="" size="20" tabindex="8" /></label>
    
        <input type="button" name="submit" value="<?php _e('Register'); ?> &raquo;" tabindex="10" onclick="al_register();"/>
        <span id="al_registerMessage">A password will be mailed to you.</span>
    
        <a href="javascript:al_showLogin();">Log in</a> | <a href="javascript:al_showLostPassword();">Lost password?</a>
        </form>
    </div>
    </div>
    
    <div id="al_lostPassword" class="al_nodisplay">
    <div class="title">
    <h2>Retrieve password</h2></div>
    <div id="al_login2">
        <form name="al_lostPasswordForm" onsubmit="return false;" id="al_lostPasswordForm" action="#" method="post">
    	<label><?php _e('User') ?>:<input onkeypress="return al_retrievePasswordOnEnter(event);" type="text" name="user_login" value="" size="20" tabindex="7" /></label>
        <label><?php _e('E-mail') ?>: <input onkeypress="return al_retrievePasswordOnEnter(event);" type="text" name="user_email" value="" size="20" tabindex="8" /></label>
    
        <input type="button" name="submit" value="<?php _e('Retrieve'); ?> &raquo;" tabindex="10" onclick="al_retrievePassword();"/>
        <span id="al_lostPasswordMessage">A confirmation mail will be sent to your e-mail address.</span>
    
        <a href="javascript:al_showLogin();">Log in</a> | <a href="javascript:al_showRegister();">Register</a>
        </form>
    </div>
    </div>
    
    <?php   } else {    
    
    /*******   This part is drawn when user IS logged in.   *******/ ?>  
    
     <div class="title"><h2>Logged in as <a href="<?php echo get_settings('siteurl');  ?>/wp-admin/"><?php echo $user_identity; ?></a></h2></div> 
    
    <ul><li>
    <a href="<?php echo wp_logout_url('/wp-login.php?action=logout&amp;redirect_to=' . $_SERVER['REQUEST_URI']); ?>" title="Log out">Log out</a>
    </li> </ul>   <?php   } ?>
  2. WEB11
    Member
    Posted 5 years ago #

    Thanks for sharing. This part is what I was looking for:

    <li>
    <a href="<?php echo wp_logout_url('/wp-login.php?action=logout&amp;redirect_to=' . $_SERVER['REQUEST_URI']); ?>" title="Log out">Log out</a>
    </li>
  3. SuperMAG
    Member
    Posted 5 years ago #

    doesn't work, can you show me your site, or even post the complete plugin you use that work with 2.7.

  4. hal9000
    Member
    Posted 5 years ago #

    unfortunately this doesnt work.
    i have tried putting the code as you say in both places and when attempting to login it still shows the login page in the old fashioned way.

    What i really want is the login page to open up a lightbox type screen with the login request box in it!

  5. mayan212
    Member
    Posted 5 years ago #

    i'm also looking for a lightbox screen type interface, where after login takes back to the same page.

  6. HappyApple
    Member
    Posted 5 years ago #

    AJAX Login allows you to place a widget in you sidebar for quick login. After it confirms your username and password it refreshes to same page you were on last or redirects you the page you set in the dashboard settings.

    The plugin can be downloaded from Here.

    Sorry, but the creator of the plugin didn't make it with a lightbox interface. It's just a widget for instant login on your blog.

    Hope this helps. :)

  7. do77
    Member
    Posted 5 years ago #

    I was looking for a way to fix the logout issue. Works perfectly. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic