The following piece of code in the store module adds a role "0" or anon to the user_roles table. It's supposed to only add roles that have been selected by the user in the recurring product definition for role promotion. But, it tries to add an empty and 0 role even if no roles are selected to promote. This is not a good situation since 0 is a virtual role in drupal.
function store_change_role($txn, $add_to_roles) {
$txn = (object)($txn);
$u = user_load(array('uid' => $txn->uid));
$on_payment_roles = array_flip((array) variable_get('on_payment_roles', ''));
$roles = user_roles();
if ($u->uid >= 1 && is_array($on_payment_roles)) {
// If PAID - add user to role, else drop 'em
if ($add_to_roles) {
foreach($on_payment_roles as $rid => $rname) {
if (!isset($u->roles[$rid])) {
watchdog('ecommerce', t('Adding %name to role %role.', array('%name' => theme('placeholder', $u->name), '%role' => theme('placeholder', $roles[$rid]))));
$u->roles[$rid] = '';
}
}
user_save($u, array('roles' => $u->roles));
}
Comments
Comment #1
dvdweide commentedThis bug has already been reported. See this issue
A patch is available there, too!
Danny