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

Jordi Canals jordi at jcanals.net
Sat Aug 8 10:49:02 UTC 2009


I checked your suggestion, and registered a user on my test site. Seen
that the user capabilities are set as soon has the user registers on
the site.
Almost in my case as soon has the user registered, It has the default
site capability, so it won't work to see if user has logged in or not.

A proper setting for user_status could be used for this. I've been
doing a code search and looks like the user_status is never set to any
value, just the default value when creating the user. Also, I know
that user_status is used on bbPress, but have to investigate how
bbPress uses this field to make a patch proposal.

Regards,
--
Jordi Canals
http://alkivia.org
http://jcanals.net

2009/8/8 John Blackbourn <johnbillion+wp at gmail.com>
>
> 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
> else
>    // user has never logged in
>
> Definitely the need for a proper API method though.
>
> HTH, John.
>


More information about the wp-hackers mailing list