1

in drupal 7 - I have given a role the permissions to edit, add delete and modify content but he doesn't see the authored date in order to modify it. how can I give him permissions to modify that ?

1 Answer 1

2

Updated date is set automatically by the system, if you want to edit that you will need to write some custom code. Your user should be able to see the 'authored date' though.

Alternatively, if you need a date field that the user can edit (say, a publication date), just create a date field on your content and render it appropriately.


[edit based on additional info]:

I went digging in the code and found this in node.pages.inc:

$form['author'] = array(
  '#type' => 'fieldset',
  '#access' => user_access('administer nodes'),
  '#title' => t('Authoring information'),
  '#collapsible' => TRUE,
  '#collapsed' => TRUE,
  '#group' => 'additional_settings',
  '#attributes' => array(
    'class' => array('node-form-author'),
  ),
  '#attached' => array(
    'js' => array(
      drupal_get_path('module', 'node') . '/node.js',
      array(
        'type' => 'setting',
        'data' => array('anonymous' => variable_get('anonymous', t('Anonymous'))),
      ),
    ),
  ),
  '#weight' => 90,
);

As you can see, access is tied to the 'administer nodes' permission which I'm guessing you haven't, and probably don't want to give to that role.

Luckily this is quite easy to change using hook_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id), here's the API for that function.

Create a custom module and put this in it:

function MODULENAME_form_node_form_alter(&$form, &$form_state, $form_id){

    // You may wish to add some logic here to test for a specific role

    $form['author']['#access'] = TRUE;

    // Otherwise this will simply give everyone who can create nodes the
    // ability to change author and date.

}
2
  • Hi, that is the date I want him to see (the authored date) but it's not visible to him (I can see it when I edit as an admin though)
    – Diana
    Mar 19, 2015 at 12:58
  • Updated answer.
    – Darvanen
    Mar 20, 2015 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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