Forums

[resolved] How to mark user that he's logged in (8 posts)

  1. shoolty
    Member
    Posted 1 year ago #

    Hello guys.

    Actually i am making my own theme with wordpress and i have a problem. I need to mark user that he's logged in and i can;t find an api for this. Actually i am using
    wp_login($username, $password, $deprecated);
    to check if user have entered good password and username but i have no idea how to after this mark him that he's logged in!
    I should also add that i don't want to use page wp-login, i am trying to make my own 'log in form' from the site.

    Any ideas?

    Greetings

  2. jeremyclark13
    Moderator
    Posted 1 year ago #

    You could use this code.

    <?php if (is_user_logged_in()){ ?>
    This will display that the user is logged in
    <?php } else { ?>
    This will display when the user isn't logged in
    <?php } ?>
  3. shoolty
    Member
    Posted 1 year ago #

    yea i know that, and actually also using it: when he isn't logged in - shows a form to loggin, but when he is logged in show 'Welcome $username' but
    i just want to get my user logged into the account after he entered good username and password. Just to mark him 'now dude u r logged!'

    I guess it's a matter of a setting a cookie, am i right?

  4. jeremyclark13
    Moderator
    Posted 1 year ago #

    Okay I see you just need the login form.

    <form action="<?php bloginfo('siteurl'); ?>/wp-login.php" method="post" id="loginform">
    <label>Username: <input type="text" id="user_login" class="text" name="log" tabindex="10"/></label>
    <label>Password: <input type="password" id="user_pass" class="text" name="pwd" tabindex="11"/></label>
    <input type="submit" id="wp-submit" value="Log In" />
    <input type="hidden" name="redirect_to" value="<?php echo "http://".$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI']; ?>" />
    <input type="hidden" name="testcookie" value="1" />
    </form>
  5. shoolty
    Member
    Posted 1 year ago #

    :)

    But it still doesn't work with your code, because it's not creating a cookie. So it's not entering the function:

    <?php  if (is_user_logged_in()){
    print 'welcome, u r logged in'
    }
    ?>
  6. jeremyclark13
    Moderator
    Posted 1 year ago #

    It works fine on my site.

  7. shoolty
    Member
    Posted 1 year ago #

    AGROAH!
    jeremyclark13 you are my personal god!

    it works of course i just placed above empty <form> so it wasn't working because of this.

    Thanks!

  8. jeremyclark13
    Moderator
    Posted 1 year ago #

    Glad you got it working.

Topic Closed

This topic has been closed to new replies.

About this Topic