When creating a user from code and adding a role in hook_user_presave(), I get the following notices:
Notice: Undefined property: stdClass::$uid in role_watchdog_user_save() (line 162 of /sites/all/modules/contrib/role_watchdog/role_watchdog.module).
Notice: Undefined property: stdClass::$uid in _role_watchdog_add_role() (line 239 of /sites/all/modules/contrib/role_watchdog/role_watchdog.module).
Notice: Undefined property: stdClass::$uid in _role_watchdog_add_role() (line 252 of /sites/all/modules/contrib/role_watchdog/role_watchdog.module).
Notice: Undefined property: stdClass::$uid in _role_watchdog_add_role() (line 254 of /sites/all/modules/contrib/role_watchdog/role_watchdog.module).
I think it's best to add a check for the $account->uid in role_watchdog_user_presave(). If there is a better way please let me know.
/**
* Implements hook_user_presave().
*/
function role_watchdog_user_presave(&$edit, $account, $category) {
if (isset($edit['roles']) && isset($account->uid)) {
role_watchdog_user_save((isset($account->uid) ? $account->uid : FALSE), $edit, $account);
}
if (isset($account->uid) && array_key_exists('status', $edit)) {
role_watchdog_user_block($account, $edit['status']);
}
}
Comments
Comment #1
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs for DrupalFit commentedComment #2
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs for DrupalFit commentedFixed in latest release.