[wp-hackers] How to know if a user has never logged in?

John Blackbourn johnbillion+wp at gmail.com
Sat Aug 8 03:17:51 UTC 2009

The way that I do it is to check for the wp_capabilities usermeta
field. This value only gets set to something the first time a user
logs in. Not ideal, but saves adding an extra meta field.

if ( get_usermeta( $user_id, $wpdb->prefix . 'capabilities' ) )
    // user has logged in at least once
    // user has never logged in

Definitely the need for a proper API method though.

HTH, John.

2009/8/7 Jordi Canals <jordi at jcanals.net>:
> Hi to all,
> I'm writing a plugin for on site who want to prune all users that have never
> logged in. It has be done one week after registration.
> I have the registration date on the users table but  didn't find in the API
> nor the database any field that tracks id the use has logged in after
> registering.
> What I've done is: to save a user metadata with the last login date. and use
> this to know if them have ever logged to the blog.
> Just want to know if WP provides a better way to know if a user has ever
> logged into the blog.
> Thanks in advance,
> ---
> Jordi Canals
> http://alkivia.org
> http://jcanals.net
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list