• Resolved shoolty

    (@shoolty)


    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

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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 } ?>

    Thread Starter shoolty

    (@shoolty)

    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?

    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 "https://".$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI']; ?>" />
    <input type="hidden" name="testcookie" value="1" />
    </form>

    Thread Starter shoolty

    (@shoolty)

    ??

    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'
    }
    ?>

    It works fine on my site.

    Thread Starter shoolty

    (@shoolty)

    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!

    Glad you got it working.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to mark user that he’s logged in’ is closed to new replies.