I’m working on a plugin needing to return avatars a specific way. If the user exists in the wp_users table the code is run else a different set of code is run if the user is not in the wp_users table. I cannot use the username_exist and am tinkering now with the idea of using the user_status value of 0.
From the Codex, code is possible to return information based on the user_status
$blogusers = get_users('user_status=0');
foreach ($blogusers as $user) {
echo '<li>' . $user->user_email . '</li>';
}
This returns the email address for the users in the wp_users table.
But I want to use a conditional…
The following works on a local development server in which $id is 1. But not everyone using the plugin will have just this one user id …
if ( $id == '1' ) {
// echo 'User ID is ' . $id;
// Do something here
} else {
// the user is not in WordPress do something cool
}
How can I use the user_status in a conditional to check if the user_status is 0 then do something else run the code the user not being in the WP users table.
In other words, how can I write a conditional to check user_status = 0
?
Did you try username_exists