Skip to content

Instantly share code, notes, and snippets.

@piyuesh23
Last active August 29, 2015 14:02
Show Gist options
  • Save piyuesh23/0dcc69e0b81e0752a4ef to your computer and use it in GitHub Desktop.
Save piyuesh23/0dcc69e0b81e0752a4ef to your computer and use it in GitHub Desktop.
Sets user field to a specific value.
$results = db_select('users', 'u')
->fields('u', array('uid', 'created'))
->condition('uid', 0, '<>')
->condition('uid', 1, '<>')
->range(0,300)
->orderBy('created')
->execute()->fetchAll();
foreach($results as $result) {
$user = user_load($result->uid);
$user->field_profile_recieve_alerts['und'][0]['value'] = 1;
$user->field_profile_receive_discussion['und'][0]['value'] = 1;
user_save($user);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment