Reply To: Limit tags to a pre-defined list?
FINAL CODE HERE.
FOR CHECK BOXES.
(Difference from the upper one: fixed issue with tags with more than 1 word)
function displayTagElements($selectedTags, /* $userRole, */ $task){
$html= array();
$tags = get_categories(array('hide_empty' => 0, 'taxonomy' => 'topic-tag'));
$selectedTagsArray = explode(',', $selectedTags);
if($userRole != 'bbp_participant' || $task != 'edit') {
$html[] = "";
foreach($tags as $tag) {
$selected = '';
if (in_array($tag->name, $selectedTagsArray)) {
$selected = 'checked';
}
$html[] = "<input type='checkbox' name='bbp_topic_tags[]'".$selected." value='". $tag->name ."'>". $tag->name ." ";
}
} else {
$html[] = $selectedTags;
}
return implode('', $html);