• Resolved Phil Marnell

    (@entrepreblog)


    I’m using this query to fetch editors or contributors – but it’s finding inactive records for both.

    $results = $wpdb->get_results(“SELECT distinct user_email as em from $wusers inner join $wmeta on ID = user_id WHERE meta_key like ‘%capabilities%’ and meta_value REGEXP ‘editor|contributor’ and user_email <> $thisUsersEmail”, ARRAY_A);

    I’ve eyeballed records for active/inactive users at the db level, but don’t see anything to distinguish status. I’ve looked in forums, and also on Google w/o finding a solution.

    Is there a field or method for determining which user records are active, and which are inactive/deleted?

    • This topic was modified 4 years, 10 months ago by Jan Dembowski.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    How would you define “inactive”?

    Have you looked at the user_status column?

    Thread Starter Phil Marnell

    (@entrepreblog)

    When a user is removed, the records stay in the database, but they’re not displayed in the dashboard USERS dialog. I suppose I could drill into that and see how they are distinguished.

    And, yes, I looked at user_status first – made sense. But everything I’ve seen says it’s deprecated. I looked again, and all values for user_status are ‘0’, including deleted users.

    Thanks.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Are you on multisite or something special like that?

    Deleting a user actually deletes the row from the table, in a simple installation. It does more than that too, but you can’t get back deleted data from a query.

    So, if you’re on multisite, then deleting a user from a site just removes them from that site, it doesn’t remove the account as a whole since they might be on other sites. Which is why multisite setups have a “deleted” column for actually deleted users.

    Thread Starter Phil Marnell

    (@entrepreblog)

    Resolved. Changed status to ‘not a support question’.

    It’s not multi-site, but there is more than one site, and I suspect I was viewing frontend on one, and looking at db for another.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Select ACTIVE users only’ is closed to new replies.