How to add Remember me function at custom login box ?

Posted by morningglory on Stack Overflow See other posts from Stack Overflow or by morningglory
Published on 2010-04-26T08:33:09Z Indexed on 2010/04/26 8:43 UTC
Read the original article Hit count: 239

Filed under:
|
|

In my theme, there's custom page for the login. Login function at functions.php is like this

   function log_in($username, $password) {

    $user = parse_user($username);

    $username = $username;
    $password = $password;

    if(isEmptyString($username)) return new WP_Error('username', 'required');
    if(isEmptyString($password)) return new WP_Error('password', "required");
    if(!wp_check_password( $password, $user->user_pass ) ) return new WP_Error('wrong_password', "wrong");

    wp_set_auth_cookie($user->ID, $remember);
    wp_login($username, $password);

    redirect_profile();

}

function parse_user($info = null, $return = 'object') {
    if ( is_null( $info ) ) {
        global $current_user;
        if ( empty( $current_user->ID ) ) return null;
        $info = get_userdata( $current_user->ID );
    }
    elseif ( empty( $info ) ) {
        return null;
    }
    if( $return == 'ID' ) {
        if ( is_object( $info ) ) return $info->ID;
        if ( is_numeric( $info ) ) return $info;
    }
    elseif( $return == 'object' ) {
        if ( is_object( $info ) && $info->ID) return $info;
        if ( is_object( $info )) return get_userdata( $info->ID );
        if ( is_numeric( $info ) ) return get_userdata( $info );
        if ( is_string( $info ) ) return get_userdatabylogin( $info );
    }
    else {
        return null;
    }
}

I want to add remember me checkbox for user to logged in all the time until they logout. How can i add this ? Please kindly help me out. Thank you.

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about php