WordPress.org

Ready to get started?Download WordPress

Forums

login to wordpress from main page (10 posts)

  1. keaide
    Member
    Posted 8 years ago #

    Hi,

    I want to integrate the login, the wordpress login (wp-login) into my main page. I have my wordpress installed in a folder and showing it out in my main page (the root index.php). Is it possible for me to login from my index.php page?

  2. incredipete
    Member
    Posted 8 years ago #

    You just need the one line of code somewhere on you main page somewhere: <?php wp_loginout(); ?>

  3. keaide
    Member
    Posted 8 years ago #

    sorry for not being detailed enough, ya I have the <?php wp_loginout(); ?> in my index.php.

    but I am wondering if its possible to have a form in my main index.php page which allows me/others to key in login info (username and password). Then after they submitted, they will be directed to the admin page.

  4. incredipete
    Member
    Posted 8 years ago #

    I see, so you want to put the fields from the login screen onto your page... got it.

    That's a damn good question, and now i'm going to spend some time working on it...

  5. JuryDuty
    Member
    Posted 8 years ago #

    Yep! It's possible. Here's the code I use:

    <id="login">
    <?php
    global $user_ID, $user_identity;
    get_currentuserinfo();
    if (!$user_ID):
    ?>
    <form name="loginform" id="loginform" action="<?php echo get_settings('siteurl'); ?>/wp-login.php" method="post">
    <div><label><?php _e('Username') ?>:<input type="text" name="log" id="log" value="" size="15" tabindex="7" /></label><br />
    <label><?php _e('Password') ?>: <input type="password" name="pwd" id="pwd" value="" size="15" tabindex="8" /></label>
    <input type="submit" name="Login" value="<?php _e('Login'); ?> &raquo;" tabindex="9" />
    <?php wp_register('', ' <i>Registration is FREE and gives you the ability to post comments.</i>'); ?>
    <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/></div>
    </form>
    <?php
    else:
    ?>
    <ul>
    <?php wp_register(); ?>
    <li><a href="<?php echo get_settings('siteurl') . '/wp-login.php?action=logout&amp;redirect_to=' . $_SERVER['REQUEST_URI']; ?>"><?php _e('Logout'); ?></a></li>
    </ul>
    <?php
    endif;
    ?>
    </li>

  6. JuryDuty
    Member
    Posted 8 years ago #

    PS You can see it in action on the left side of my page.

    http://www.thechristianguitarist.com

  7. Kafkaesqui

    Posted 8 years ago #

    -Nevermind-

    Suggestion is "hidden" in code above.

  8. JuryDuty
    Member
    Posted 8 years ago #

    One more tidbit. If you don't want it to say "Site Admin" when people are logged in, go to your wp-includes directory and open the file template-functions-general.php. Search for "Site Admin" and change it to "View Profile" or whatever you want.

  9. keaide
    Member
    Posted 8 years ago #

    wow, so many replies I've got... thanks guys! I will experiment it once my host is up. Its a pity I cannot try them out yet since my host is down.

  10. varunkrish
    Member
    Posted 8 years ago #

    can i login to wordpress from php code itself without revealing the info to the user ?

    i mean no form nothing.....

    they are automatically signed it to wordpress with some role.
    how do i do that?

Topic Closed

This topic has been closed to new replies.

About this Topic