• 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?

Viewing 9 replies - 1 through 9 (of 9 total)
  • You just need the one line of code somewhere on you main page somewhere: <?php wp_loginout(); ?>

    Thread Starter keaide

    (@keaide)

    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.

    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…

    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>

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

    https://www.thechristianguitarist.com

    -Nevermind-

    Suggestion is “hidden” in code above.

    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.

    Thread Starter keaide

    (@keaide)

    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.

    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?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘login to wordpress from main page’ is closed to new replies.