So I've been developing a module, which automatically-assigns roles based on taxonomy terms in user profiles. I can do that fine - but I wanted to add a settings page to the module that allows you to choose which vocabularies to assign roles for.
In the _settings hook, there is this code:
$vocabularies = array();
foreach (module_invoke('taxonomy', 'get_vocabularies') as $vocabulary) {
$vocabularies[$vocabulary->vid] = $vocabulary->name;
}
$form['autorole_vocab_select'] = array('#type' => 'checkboxes',
'#title' => t('Vocabularies to auto-generate roles for'),
'#default_value' => variable_get('autorole_vocab_select', 1),
'#options' => $vocabularies,
'#description' => t('Which vocabularies to auto-generate roles for'));
}
If I understand correctly, variable_get['autorole_vocab_select'] should contain the values that were selected in the settings page (and the database table variables reflects this correctly as well).
in the function that assigns the roles, this code is present:
$allowed = variable_get('autorole_vocab_select', 'none');
foreach($allowed as $vocab) {
$terms[] = module_invoke('taxonomy','taxonomy_get_tree', $vocab->vid);
}
It then checks that the field type the function got passed is a vocabulary, and checks that the name of it is in $terms - which should contain the vocab terms under the vocabularies that were selected, however if any vocabulary terms were selected, it acts as if all of them were selected. If none are selected it works as would be expected. Since the variable in the database table "variables" is correct, I assume that the problem must be in the $allowed = variable_get('autorole_vocab_select', 'none');
call.