Forums

wp_login_form(); not working? (4 posts)

  1. Azim
    Member
    Posted 1 year ago #

    I've faced an unexpected stuff - when I add wp_login_form(); to the template, it doesn't do anything. The login form appears, but when I enter my login and password, it just reloads and still shows me the form, as if I haven't done anything - no error, no "welcome", just reload. Then when I go to /wp-admin/, I have an access - so that means my password has been received successfully, but it didn't tell I've authorized successfully.
    I'm trying this on 2010 theme also - same results.
    What have I deen doing wrong?

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    It redirects to the same page by default. If you want it to redirect to your wp-admin try something like this:
    <?php wp_login_form('redirect=/wp-admin'); ?>

  3. Azim
    Member
    Posted 1 year ago #

    I don't need it to go to admin. I want it to display the results of authorizations, like "Welcome, username" or whatever... Or "wrong password". Now it just doesn't give me anything, it reloads and shows the form again - how am I supposed to know if I logged in or failed?

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    try something like this:

    global $user_login;
    if (is_user_logged_in()) {
        echo 'Hello, ', $user_login, '. <a href="', wp_logout_url(), '" title="Logout">Logout</a>';
    } else {
        wp_login_form();
    }

Topic Closed

This topic has been closed to new replies.

About this Topic