<?php $usernames = ['username1', 'username2', ...]; // An array of the usernames of the users you want to change the role for $new_role = 'new_role'; // The new role you want to assign to the users foreach ($usernames as $username) { $user = get_user_by('login', $username); if (!empty($user)) { $user->set_role($new_role); } } ?>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter