The MU forums have moved to WordPress.org

How to get a login on the front page - a la iblogs.com (95 posts)

  1. macuser9214
    Member
    Posted 15 years ago #

    got it on the front BLOG page. now how about on my main page?

    I think i need to do a <?php include ___ ?>

    any help?

  2. macuser9214
    Member
    Posted 15 years ago #

    basically, i just want a login form, where it says member login, on the left side of http://macuser914.com

  3. macuser9214
    Member
    Posted 15 years ago #

    no one knows how to call the script on the main page?

  4. macuser9214
    Member
    Posted 15 years ago #

    I got AuthUI working on the BLOG, but how do I include it on the main homepage, in a different directory.

    the blog is in /blog. the main homepage is in the root directory.

    SOMEONE PLEASE HELP!

  5. macuser9214
    Member
    Posted 15 years ago #

    Got it working with THIS: (replace site url with your BLOG url)

    <form name="loginform" id="loginform" action="(SITEURL)" method="post">

    <label>Username:<input type="text" name="log" id="log" value="" size="20" tabindex="1" /></label>

    <label>Password: <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="2" /></label>

    <label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />Remember me</label>

    <input type="submit" name="submit" id="login" value="Login »" tabindex="4" />

    </form>

  6. macuser9214
    Member
    Posted 15 years ago #

    problem now is that it shows the form even if the user logged in.

  7. lunabyte
    Member
    Posted 15 years ago #

    if ( !is_user_logged_in() ) {
    
    // show login form
    <!-- add html for form here -->
    
    } else {
    // user is logged in, so let's show a search form
    <!-- add search form html here -->
    }

    Simple as that.

    Or, you can change up the second part to show a welcome message, or whatever you want instead of a login.

  8. macuser9214
    Member
    Posted 15 years ago #

    <?php if ( !is_user_logged_in() ) {

    LINE 64: <form name="loginform" id="loginform" action="http://macuser9214.com/blog/wp-login.php" method="post">

    <label>Username:
    <input type="text" name="log" id="log" value="" size="20" tabindex="1" /></label>

    <label>Password:
    <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="2" /></label>

    <label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />Remember me</label>

    <input type="submit" name="submit" id="login" value="Login »" tabindex="4" />

    </form>

    } else {
    // user is logged in, so let's show logout button
    LOGOUT
    }
    ?>

    Thats what I have now, and it returns:

    Parse error: parse error, unexpected '<' in /www/(PATH)/index.php on line 64

  9. macuser9214
    Member
    Posted 15 years ago #

    Bump ->Anyone?

  10. demonicume
    Member
    Posted 15 years ago #

    look for why the computer might be confused by the ''<'' and there's your answer

  11. macuser9214
    Member
    Posted 15 years ago #

    no clue. I don't know php at all.. Just some HTML.

    So please help me. The only thing I see is the { in the top line. Is that doing it?

  12. dsader
    Member
    Posted 15 years ago #

    Looks like it needs

    ?><form>
    and later
    </form><?php
  13. macuser9214
    Member
    Posted 15 years ago #

    now it's saying line 78, which is my link to the logout button. How do I make it show the logout, only if someone is logged in?

  14. dsader
    Member
    Posted 15 years ago #

    Same thing, maybe,

    </form>
    <?php
    } else {
    
    // user is logged in, so let's show logout button
    ?>
    LOGOUT HTML
    <?php
    }
    ?>
  15. macuser9214
    Member
    Posted 15 years ago #

    Now I get

    Fatal error: Call to undefined function: is_user_logged_in() in

  16. dsader
    Member
    Posted 15 years ago #

    Replace

    <?php if ( !is_user_logged_in() ) {

    with

    <?php global $user_level;
    
    	if ( isset($user_level) ) {
  17. dsader
    Member
    Posted 15 years ago #

    whoops, add a ! if needed to

    if ( isset($user_level) ) {

    become

    	if ( !isset($user_level) ) {
  18. macuser9214
    Member
    Posted 15 years ago #

    now it logs me in but doesn't show the logout button once I do, and doesn't get rid of the login form. Here's my whole code:

    Member Login:<br>

    <?php global $user_level;

    if ( !isset($user_level) ) {

    ?><form name="loginform" id="loginform" action="http://macuser9214.com/blog/wp-login.php" method="post">

    <label>Username:
    <input type="text" name="log" id="log" value="" size="20" tabindex="1" /></label>

    <label>Password:
    <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="2" /></label>

    <label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />Remember me</label>

    <input type="submit" name="submit" id="login" value="Login »" tabindex="4" />

    </form>
    <?php
    } else {

    // user is logged in, so let's show logout button
    ?>
    LOGOUT
    <?php
    }
    ?>

  19. dsader
    Member
    Posted 15 years ago #

    Works for me. Try emptying browser cache.

  20. macuser9214
    Member
    Posted 15 years ago #

    no, the form works, but when you log in, it doesn't show a logout button, and it doesn't get rid of the account.

    I'll make a test account for you to test it with:

    http://macuser9214.com

    username: test123
    Password: wordpress

  21. macuser9214
    Member
    Posted 15 years ago #

    come on! I'm so close!

    anyone?

  22. demonicume
    Member
    Posted 15 years ago #

    • the plugin mentioned above works for me.

    • did you ever check the homeland stupidity?this should work with, no problem.

    '<li id="login">
    <?php
    global $user_ID, $user_identity;
    get_currentuserinfo();
    if (!$user_ID):
    ?>
    <h2><?php _e('Login'); ?></h2>
    <form name="loginform" id="loginform" action="<?php echo get_settings('siteurl'); ?>/wp-login.php" method="post">
    <div><label><?php _e('Login') ?>:
    <input type="text" name="log" id="log" value="" size="20" tabindex="7" /></label>
    <label><?php _e('Password') ?>:
    <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="8" /></label>
    <label><input type="checkbox" name="rememberme" value="forever" tabindex="9" /> <?php _e("Remember me"); ?></label>
    <input type="submit" name="submit" value="<?php _e('Login'); ?> »" tabindex="10" />
    <?php wp_register('', ''); ?>
    <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/></div>
    </form>
    <?php
    else:
    ?>
    <h2><?php echo $user_identity; ?></h2>

    <?php
    endif;
    ?>
    '

  23. macuser9214
    Member
    Posted 15 years ago #

    Nope,

    Fatal error: Call to undefined function: get_currentuserinfo() in /www/(PATH)/index.php on line 70

  24. macuser9214
    Member
    Posted 15 years ago #

    Kinda got it, because I'm using SMF with it, andI can use SSI logout for SMF, and it will log me out, but the form still shows

  25. macuser9214
    Member
    Posted 15 years ago #

    Doesn't there have to be a part that basically says:

    The user logged in, now we need to get rid of the login form?

  26. lunabyte
    Member
    Posted 15 years ago #

    if ( !is_user_logged_in() ) {
    // login form
    } else {
    // logged in info
    }
    
  27. macuser9214
    Member
    Posted 15 years ago #

    Then I have:
    Member Login:<br>
    (LINE 66)---> <?php if ( !is_user_logged_in() ) { ?>
    <form name="loginform" id="loginform" action="http://macuser9214.com/blog/wp-login.php" method="post">

    <label>Username:
    <input type="text" name="log" id="log" value="" size="20" tabindex="1" /></label>

    <label>Password:
    <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="2" /></label>

    <label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />Remember me</label>

    <input type="submit" name="submit" id="login" value="Login »" tabindex="4" />

    </form>}
    <?php }
    else { ?>
    LOGOUT (if logged in)
    <?php } ?>

    which gives me: Fatal error: Call to undefined function: is_user_logged_in() in /www/PATH/index.php on line 66

  28. macuser9214
    Member
    Posted 15 years ago #

    can someone just post a working copy of the code? My blog URL is http://macuser9214.com/blog, and this page for the login form is http://macuser9214.com/index.php.

    How does the script know to call Wordpress to get the user_logged_in function? I think I'm missing something in the beginning of my index.php file....

    SOMEONE HELP! I wanna get this working!

  29. lunabyte
    Member
    Posted 15 years ago #

    How does the script know to call Wordpress to get the user_logged_in function?

    Because it's supposed to be called from a WP template?

    If you're outside of WordPress, that's a whole nother ball of wax.

  30. macuser9214
    Member
    Posted 15 years ago #

    THAT was the problem then.. Yeah I'm' outside of wordpress....

    Any help?

About this Topic

  • Started 17 years ago by Farms
  • Latest reply from franz.skaaning