WordPress.org

Ready to get started?Download WordPress

Forums

Can I pass two roles to the function get_users? (1 post)

  1. nicolaelvin
    Member
    Posted 1 year ago #

    I want to get the users of role academic and student. I have tried using the code below (passing an array of roles, but all users are being displayed, so clearly it's not working.

    $roles=array('academic','student');
    $args =array('role'=>$roles);
    $users=get_users( $args );
    
    foreach ($users as $user) {
        echo '<li>' . $user->user_email . '</li>';
    }

Topic Closed

This topic has been closed to new replies.

About this Topic