Created
July 16, 2015 07:35
-
-
Save MatthieuScarset/162735b0796e82159e8f to your computer and use it in GitHub Desktop.
Drupal - Select and update all users by role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Select and update user by role | |
$role = user_role_load_by_name('blogger'); | |
$query = 'SELECT ur.uid FROM {users_roles} AS ur WHERE ur.rid = :rid'; | |
$result = db_query($query, array(':rid' => $role->rid)); | |
$uids = $result->fetchCol(); | |
$users = user_load_multiple($uids); | |
foreach($users as $user) { | |
// $user->field_to_update['und'][0]['value'] = 1; | |
// user_save($user); | |
dpm($user); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment