WordPress.org

Ready to get started?Download WordPress

Forums

login form like wp.com (5 posts)

  1. ergate
    Member
    Posted 8 years ago #

    Hi,
    I would like to add a login form to my sidebar, similar in function to the login form on wordpress.com.
    When the user logs in, the form disappears and a user identity message is displayed. I know how to put the register, login / logout links on the page, and I can get a login form on the page, but I cannot figure out how to make it go away once logged in.
    I am using this post to display the user identity message.
    I know it should go into a if, else or something like that, but I cannot figure out the check for login process.

  2. Kafkaesqui

    Posted 8 years ago #

    Taking skippy's code from the thread linked to, you can do:

    global $user_identity;
    get_currentuserdata();
    if ($user_identity) {
    echo "Hi $user_identity!";
    } else {
    wp_loginout();
    }
    ?>

    Add to our replace wp_loginout(); with whatever you need to display when one is not logged in.

  3. ergate
    Member
    Posted 8 years ago #

    is that function in 2.0.
    I am getting this error

    Fatal error: Call to undefined function: get_currentuserdata() in /home/.../wp-content/themes/complaint_main/sidebar.php on line 16

  4. Kafkaesqui

    Posted 8 years ago #

    Sorry, copied over skippy's block without reading through it. The function should be get_currentuserinfo().

  5. ergate
    Member
    Posted 8 years ago #

    Brilliant,
    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.