Initialize a field in all users profiles

Public

Get raw version
php
  1. $users = entity_load('user');
  2.  
  3. foreach ($users as $user) {
  4. $wrapper = entity_metadata_wrapper('user', $user);
  5. if ($wrapper->uid->value() != 0) {
  6. //dpm($wrapper->getPropertyInfo());
  7. $wrapper->field_receiveemail = 1;
  8. $wrapper->save();
  9. }
  10. }