Last active
March 16, 2016 08:50
-
-
Save teknikqa/9031690996e8c5e2c0b0 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* This script will initialize the fields for controlling research and publications | |
* with the default value for all users. This field was added later and so this | |
* step is necessary. | |
* | |
* Run this script only if email notifications are disabled or if reroute email | |
* is enabled. | |
* | |
* To run this script, | |
* drush @env scr initialize_user_fields.php | |
* | |
* @author Nick Mathew <https://nm7.org> | |
* @date 2016-03-15 | |
*/ | |
$users = entity_load('user'); | |
foreach ($users as $user) { | |
$wrapper = entity_metadata_wrapper('user', $user); | |
if ($wrapper->uid->value() != 0) { | |
//dpm($wrapper->getPropertyInfo()); | |
// Replace these with the fields that you want to update | |
$wrapper->field_control_research = 0; | |
$wrapper->field_control_publication = 0; | |
$wrapper->save(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment