1

I dont understand what is wrong my code is just not working, I have tried with different $args but still no user displays.

Following is my code:

$args = array(
    'role__in' => array('Subcriber', 'Editor','Administrator'),
);
$user_query = new WP_User_Query( $args );
$reslult = $user_query->results;
// User Loop
if ( ! empty( $user_query->results ) ) {
    foreach ( $user_query->results as $user ) {
        echo '<p>' . $user->display_name . '</p>';
    }
} else {
    echo 'No users found.';
}

Result is always no user found.

  • 2
    Subcriber is spelt wrong. Needs to be Subscriber. Does that help? – Jacob Peattie Oct 15 '17 at 7:28
1

See the example code on this URL

Correct the spelling Subscriber

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