Let users create taxonomy terms in Drupal

Drupal lets you define just about any type of content you can imagine, using the Taxonomy module.

For example, on Our Community Watch I created Taxonomy Terms for license plates, communities, cities and zip codes. As an administrator I can create new communities by adding items to each taxonomy term, but it's not safe to let regular users have that level of access (they could edit or delete other terms, which could break the site).

Here's how I created a form that allows regular users and anonymous users to add new Taxonomy Terms to a Drupal web site:

Step 1:

Create a basic page with a Title but an empty body, and make note of the resulting page's URL.

I use the Path Auto module to ensure pretty URLs, so a Title of "Create a Community" would automatically result in a URL of /create-community.

Step 2:

Create a new block, select the PHP filter option, and enter the following PHP code:

if ($vocabulary = taxonomy_vocabulary_machine_name_load('community')) {
module_load_include('inc', 'taxonomy', 'taxonomy.admin');
$edit = array();
$taxonomy_form = drupal_get_form('taxonomy_form_term', $edit ,$vocabulary);
return drupal_render($taxonomy_form);
}
?>

This code renders the form for adding a new "community" taxonomy term, where Community is a Taxonomy I had previously created.

Here's how it looks in Drupal:

Step 3:

In the "Visibility" settings near the bottom of the block configuration page, choose "Only the listed pages" and enter the URL for the page you created above.

Save your block and navigate to the page URL to view the form.

You may also want to assign a menu to that URL, so that the page is easily accessible to your users. In the case of Our Community Watch, I created a "New Community" link at the top of the site that linked to the "/create-community" URL... which displays the form for adding a new community taxonomy term.