I have a cck content type: Vehicle

Admins can create new vehicles and assign taxonomy terms to them and publish them. I would like anonymous users to be able to create new vehicles, but I do not want anonymous users to be able to assign taxonomy terms. When an anonymous user submits a vehicle, it is unpublished and goes into a queue for the admins. After an admin approves the vehicle, they can publish it and add taxonomy terms.

I have the functionality all down right now ... except the taxonomy part. I can't figure out how to hide the taxonomy form field from anonymous users.

Anybody have any idea how I can do this?

Comments

caschbre’s picture

One option would be to use the content taxonomy (http://drupal.org/project/content_taxonomy) module. It can hide the core taxonomy fields on node edit forms and instead places them into CCK fields. Then you can use the CCK field permissions (included with CCK) to now allow anonymous users to edit them.

tonyhrx’s picture

If you have more than one vocabulary on a page you can hide specific ones as follows:

Use Firebug and look at the taxonnomy wrapper ID on the node edit form. Then use CSS to set the display to none.

eg

#edit-taxonomy-1-wrapper {
display:none;
}

tonyhrx’s picture

Just read your requirement s a bit more.

Create this function in a custom module

/**
* Implementation of hook_form_alter().
*/
function default_taxonomy_form_alter(&$form, &$form_state, $form_id) {

//check to see if anonymous user

global $user;

if (!$user->uid) {

//pick what forms you want to alter
if ($form_id == 'offer_node_form' || $form_id == 'event_node_form') {

//Set some DIVs on the form with an inline style
$form['taxonomy']['#prefix'] = '<div style=display:none;>';
$form['taxonomy']['#suffix'] = '</div>';

}
}

Only problem is it hides ALL vocabularies.

I'm not sure there is a way of selecting a specific vocabulary on the form

saheel.sikilkar’s picture

For specific taxonomy you can do the following:

$form['taxonomy']['7']['#prefix'] = '<div style=display:none;>';
$form['taxonomy']['7']['#suffix'] = '</div>';

Here you can replace 7 with vocabulary id of your choice.