0

I have a taxonomy list connected with a content type. I want to give all authenticated users to access the content edit page but only see and access the taxonomy field section so users can participate in making the site more organized and accurate.

Is there a way to only show 1 field to users and allow them to edit just that one field? If so, how do i show a link on the content page to the edit page? (example: "Click here to edit/add tags" - This link would then go to the /node/2343/edit link)

My idea comes from many video sharing sites where people can add/edit "categories" or "tags" if the user has permission to do so. These sites usually have a little "+" symbol next to the categories which then opens the category check list for that piece of content for editing.

1

You can set permissions for fields who can edit or not Please have a look into this module

Field Permissions

The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.

0

Using hook form alter will allow you to do this.

function my_module_form_alter(&$form, &$form_state, $form_id) {
  // Pick which content type you want to tinker with.
  if ($form_id == 'your_custom_contenttype'){
    global $user;
// only hide fields when editing the node
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) != 'edit' {

 // Check if the user has the 'authenticated' role.
      if (in_array('authenticated', $user->roles)) {
      // Now it's time to hide all the fields you don't need
      $form['title']['#access'] = FALSE;
      $form['body']['#access'] = FALSE;
      $form['field_name_1']['#access'] = FALSE;
      $form['field_name_2']['#access'] = FALSE;
      $form['field_name_3']['#access'] = FALSE;
      //etc
    }
  }
}
}
  • forgive me for being daft, but where will I post this code? I tried posting it in the settings.php file. also, how do i test this? Will i just type in the node/NID/edit URL? as an authenticated user instead of admin? – Anon Ymous Jul 22 '14 at 20:31
  • you'll need to create a custom module to take advantage of this. If I find some time I can show you exactly how's it's done unless someone else beats me to it. You can always youtube how to build a module and google how to hide form fields. It's pretty straight forward. – Emir Memic Jul 23 '14 at 2:23
  • to help me get started with module building...The basics are: 1) add the above code the the MODULENAME.module and then add some info (which ill research) to the MODULENAME.info file??? – Anon Ymous Jul 23 '14 at 2:43
  • Yes. Take a look at this tutorial wdtutorials.com/2012/04/29/… complete step 1 and 2. I your .module file copy the above code snippet and change the elements according to your setup. Note, I modified the code by including a check to only hide the fields on node/edit. Also, make sure to check permissions so that authenticated users can edit the custom content type. – Emir Memic Jul 23 '14 at 6:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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