1

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

  • 1
    Active like logged in recently, or active like successfully created an account w/password? – jgraup Nov 7 '16 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 Nov 7 '16 at 13:38
1

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

  • Thanks Kevin. The fact is when I register a new account, although it is not active yet, the user_activation_key in users table is empty. Instead, a row is created in usermeta with activation_key as meta_key. I guess it has the same meaning ? I'm using WP v4.6.1 – Mathias C Nov 7 '16 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.