A bit of an oddball question. In Drupal 7, I have a comment form page that is required to show the allowed HTML tags available to users. The default list has been added to over time so now I have about 40 different tags.

I want to display it programmatically as part of the form, but I cannot give users the option to change the text format (I want them to use the default Filtered HTML) so I've hidden the Text Format portion of the comment form using the Simplify module.

So my question is how can I output the revised list of allowed HTML?

I've rummaged through the filter module, and tried to print the results of filter_filter_info() like so:

$filter = filter_filter_info();

but all it returns is the default list of tags that comes with vanilla Drupal, maybe 10 tags or so. It doesn't show my revised list of tags at all.

I've searched for quite some time but can't find any info on how to do this, so any help would be appreciated!

1 Answer 1

$filters = filter_list_format('filtered_html'); // put your filter name here
$tags = isset($filters['filter_html']) ? $filters['filter_html']->settings['allowed_html'] : FALSE;
  • Thanks! Missed the filter_list_format function, great find. It should be added that $tags is now a bunch of HTML tags so in order to output it I had to regex all these tags lol Nov 17, 2015 at 21:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.