I have a vocabulary with the terms AAA, BBB, CCC, DDD which I want to use as roles. If I uncheck "Prefix role with vocabulary name" in the Taxorole settings, it doesn't create the roles correctly. Instead of having the roles AAA, BBB, CCC, DDD in creates AAA, AAABBB, AAABBBCCC, AAABBBCCCDDD.

To resolve this, change

drupal_set_message(t('Created role ').$newrole.'.');

to

drupal_set_message(t('Created role ').$newrole.'.');
unset($newrole);

on line 143.

Comments

mandclu’s picture

Wouldn't it make more sense to unset $newrole at line 148, at the end of the foreach loop? Otherwise you run the risk of adding blank categories to mass contact.

kmargar’s picture

Assigned: Unassigned » kmargar
Status: Needs review » Closed (fixed)

Done, patch committed, thanks.

afox’s picture

Version: 5.x-1.x-dev » 5.x-2.x-dev
Status: Closed (fixed) » Needs review

Still does it in 2.x -version. The unset is in a wrong place:

Now:

.
.
.
drupal_set_message(t('Created role ').$newrole.'.');
  if (module_exists('mass_contact') && $form_values['taxorole_add_mass_contact_category'] == 1) {
  taxorole_mass_contact_add_category($newrole, $newrid);
  drupal_set_message(t('Added category ').$newrole.t(' in Mass Contact categories.'));
  unset($newrole);
  }
}

Should be:

.
.
.
drupal_set_message(t('Created role ').$newrole.'.');
  if (module_exists('mass_contact') && $form_values['taxorole_add_mass_contact_category'] == 1) {
  taxorole_mass_contact_add_category($newrole, $newrid);
  drupal_set_message(t('Added category ').$newrole.t(' in Mass Contact categories.'));
  }
unset($newrole);
}

This way it works for those who don't have mass_contact -module enabled.