Best way to tell if a user account is active, using the database only

admin2025-01-07  5

I'm trying to tell if a user account is active or not, outside of WP code, by looking at the database only. Seems like a bad practice for sure, but I'm kinda stuck in this situation and anyway, it seems interesting to me to know for sure how WP determines this.

After searching in the documentation and in the questions/answers, I couldn't find anything clear.

What I observed from the database is :

  • every active user has a "PREFIX_capabilities" row in "PREFIX_usermeta"
  • every pending account has a "activation_key" row in "PREFIX_usermeta"

Which indicator should I use to determine if the account is active ? Seems to me that both are equivalent, but I'm not sure this is deterministic...

Could someone please confirm this or correct me if I'm wrong ?

Thanks a lot for any advice, All the best,

Mathias

I'm trying to tell if a user account is active or not, outside of WP code, by looking at the database only. Seems like a bad practice for sure, but I'm kinda stuck in this situation and anyway, it seems interesting to me to know for sure how WP determines this.

After searching in the documentation and in the questions/answers, I couldn't find anything clear.

What I observed from the database is :

  • every active user has a "PREFIX_capabilities" row in "PREFIX_usermeta"
  • every pending account has a "activation_key" row in "PREFIX_usermeta"

Which indicator should I use to determine if the account is active ? Seems to me that both are equivalent, but I'm not sure this is deterministic...

Could someone please confirm this or correct me if I'm wrong ?

Thanks a lot for any advice, All the best,

Mathias

Share Improve this question asked Nov 7, 2016 at 11:40 Mathias CMathias C 231 silver badge4 bronze badges 2
  • 2 Active like logged in recently, or active like successfully created an account w/password? – jgraup Commented Nov 7, 2016 at 13:14
  • @jgraup Thanks. "Active" like : a user that signed up using the registration form may log in, i.e. the account was confirmed either by the user himself via the email he received, or by the administrator via Dashboard / Users Pending => activate (my WP is in french, hope the menu items names are the right ones, sfai). – Mathias C Commented Nov 7, 2016 at 13:38
Add a comment  | 

2 Answers 2

Reset to default 2

Well, it's actually in user_meta table.

    select umeta_id, meta_value from [wp_prefix]usermeta where meta_value='hp_email_verify_key'

To unlock an unverified account, you need to set its value to NULL :

    update [wp_prefix]usermeta set meta_value=NULL where umeta_id=[some_id]

Just look for an empty user_activation_key in users-table. If is empty, user is active. If is filled, user is inactive.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736256403a357.html

最新回复(0)