Drupal: using PHP in Taxonomy Redirect for anonymous users

As mentioned at drupal.org, there is an issue with Taxonomy Redirect where (at least in Drupal 5, don’t know about 6) the PHP filter doesn’t work for anonymous users. Instead of evaluating the PHP snippet, Taxonomy Redirect will return the snippet as text, resulting in very long url holding your script code. As I mentioned at drupal.org, this is probably due to the use of the filter_formats() function in taxonomy_redirect_get_php_filter() to find the right identifier for the PHP filter. Because filter_formats checks for user permissions as well, in a default Drupal install it will only return an HTML filter, and no PHP filter. As such, the identifier is set to the default value “0″, which is actually the identifier for a text filter. Hence, Taxonomy Redirect returns filtered text instead of a PHP evaluation. This can be resolved by setting the default value for the filter identifier to “2″ in line 248 of taxonomy_redirect.module (5.x-1.3):

function taxonomy_redirect_get_php_filter() {
$phpfilter = 0;
$filters = filter_formats();
foreach ($filters as $filter) {

becomes:

function taxonomy_redirect_get_php_filter() {
$phpfilter = 2;
$filters = filter_formats();
foreach ($filters as $filter) {

You may want to check whether the identifier for the PHP filter is 2 for you Drupal install. You can verify this in your Drupal database in the filter_formats table.

1 Response to “Drupal: using PHP in Taxonomy Redirect for anonymous users”


  1. 1 Drupal: Combining Taxonomy Menu and Taxonomy Redirect at Quite a Bright Light

Leave a Reply