While I understand the purpose of the "log message" field in the node create form, I would like to remove it for my clients as it simply confuses them. Does anyone have a hack yet in the form.inc file that removes this?

Comments

RobRoy’s picture

Version: 5.1 » 6.x-dev
Category: support » feature

IMO this should be a content types option so I'm setting to 6.x-dev, but for now you can create a module called remove_log_field.module with this:

/**
 * Implementation of hook_form_alter().
 */
function remove_log_field_form_alter($form_id, &$form) {
  if (isset($form['#node']) && isset($form['log']) && $form_id == $form['#node']->type .'_node_form') {
    $form['log']['#access'] = FALSE;
  }
}
Gabriel R.’s picture

Hello RobRoy,

I created the .module as you suggested but it didn't work.

Ay other suggestion would be appreciated.

Anonymous’s picture

Subscribing to post

RobRoy’s picture

@Gabriel, is this in Drupal 5?

Gabriel R.’s picture

I m using Drupal 5.1 with no alteration of the core.

The module created as described above doesn't even appear on the modules list.

Thanks.

RobRoy’s picture

Sorry, should have been more explcit. You'll need a .info file as well: http://drupal.org/node/101009.

zach harkey’s picture

If you don't feel like creating and enabling a whole module for this, it's pretty easy to override the node form at the template level by adding the following function to your template.tpl.php:

/**
 * Override node form
 */
function phptemplate_node_form($form) {
  // Remove 'Log message' text area
  $form['log']['#access'] = FALSE;
  return drupal_render($form);
}
Gabriel R.’s picture

The template change worked great.

Thanks for your help guys!

RobRoy’s picture

Category: feature » support
Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)
skassam’s picture

Any idea how to override the same field on node edit also?

TIA,
Shinan

bsobolewska’s picture

Version: 6.x-dev » 5.2

I have tried to place the code within the template.php (is it the same as template.tpl.php?) but I got the following error:

Fatal error: Cannot redeclare phptemplate_node_form() (previously declared in D:\wamp\www\portal\themes\zen\template.php:7) in D:\wamp\www\portal\themes\zen\template.php on line 518

Where the code around line 518 is:

// Add Form Start
function phptemplate_node_form($form) {
if ($form['form_id']['#value'] == 'ugevent_node_form') {
return _phptemplate_callback('event_add', array('form' => $form));
}

if ($form['form_id']['#value'] == 'qanda_node_form') {
return _phptemplate_callback('qanda_add', array('form' => $form));
}

}
// Add Form End

Then I thought that maybe template.php is indeed not the same as template.tpl.php so created one in the same folder themes\zen but nothing happened (no error and no result).

I must say I always get the same sort of error whenever trying to override the existing functions.
What am I doing wrong?
greetings,
Bogumila

Anonymous’s picture

The easiest way may possibly be a hook_form_alter implementation in a module. For the $form_id matching node/create you simply set the '#type' to 'hidden' for the log message fields.

jefftrnr’s picture

Version: 5.2 » 6.4

It looks like it works a bit differently in Drupal 6. It uses the same theme override function, but different keys in the $form array. I set it to a "hidden" type.

function phptemplate_node_form($form) {
  // Remove 'Log message' text area
  $form['revision_information']['#type'] = 'hidden';
  return theme_node_form($form);
}

Does this look wrong to anyone? It seems to work. I put it in my template.php file.

Mac Clemmens’s picture

Thanks - that did the trick for me!

I updated code just a bit to still be visible for people with the "edit post" permission:


function phptemplate_node_form($form) {
   // Remove 'Log message' text area
   $form['revision_information']['#access'] = user_access('administer posts');
   return theme_node_form($form);
}

chris_huh’s picture

I tried that (version 6.8) and it doesn't do anything. Is there something i might have done wrong?

chris_huh’s picture

Actually it works now. i think it just needed a bit of time to go through.

jim0203’s picture

@Digital Deployment:

Your code:

function phptemplate_node_form($form) {
   // Remove 'Log message' text area
   $form['revision_information']['#access'] = user_access('administer posts');
   return theme_node_form($form);
}

Is cool, but I don't seem to have the "administer posts" privilege available in my (pretty standard) D6 installation. I've therefore changed the code to:

function phptemplate_node_form($form) {
   // Remove 'Log message' text area
   $form['revision_information']['#access'] = user_access('view revisions');
   return theme_node_form($form);
}

Which links the ability to see the "Revision information" drop-down in the node creation form to the "view revisions" permission.

Using this technique you can pick a permission at will; it would be pretty simple to write a module which just added a new permission (or permissions) so you could specifically turn off the "Revision information" section of the node creation form.

On that note, could someone verify how easy it would be to write a module that allowed users to customize what sections of the node creation form were visible? I'm guessing it's just a matter of transcribing this function for each area of the node creation form and then adding the appropriate permissions to the permissions array.

damien tournoud’s picture

This is *ugly*.

The good place to do this is in a hook_form_alter() implementation, *NOT* in the theme system. It works only by chance (because the log field is not mandatory).

zach harkey’s picture

Whatever. The 'good' place to do this is through the core user interface. Specifically, in the main workflow settings for each content type.

Just like the upload module lets you enable/disable attachments, any module that adds optional fields to the node admin form should provide a way to disable the feature on a per content type basis.

raintonr’s picture

Re: #1

The D6 version of this is:

function remove_log_field_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['#node']) && isset($form['revision_information']) && $form_id == $form['#node']->type .'_node_form') {
    $form['revision_information']['#access'] = FALSE;
  }
}
francewhoa’s picture

Another option is hiding 'Revision information' using CSS. To do so add the following style anywhere in your theme stylesheet file.

fieldset.collapsible {
     display: none;    /* Hiding all collapsible fieldsets in Drupal 6.x. Including 'Revision information' fieldset. */
}

Note that this will hide all collapsible fieldsets. Not just 'Revision information' fieldset.

broon’s picture

Since I was writing my own node modules for defining content types I stumbled upon this, too. But opposing to include this in the MYMODULE_form function, I'd prefer the hook_form_alter implementation. Additionaly, I want the fields still be usable and just hide them from certain users. Fusing RobRoys (#1) and Onopocs (#22) proposals I came up with the following function to be included in my node modules:

// Invoke hook_form_alter to hide field(set)s defined by core modules.
function MYMODULE_form_alter(&$form, $form_state, $form_id) 
{
  global $user; // Bring $user object into scope if displaying shall depend on userid or role
  #if ( $user->uid != 1 ) // 0 -> Anonymous, 1 -> SuperAdmin, 2+ -> Authenticated users
  if ( !in_array('USER ROLE NAME', $user->roles) ) // Check for role (using role name)
  {
    // add class 'hideme' to elements which shall be hidden
    $form['revision_information']['#attributes'] = array('class' => 'hideme'); // Revision information
    $form['author']['#attributes'] = array('class' => 'hideme'); // Author information
    $form['options']['#attributes'] = array('class' => 'hideme'); // Publishing options
    $form['xmlsitemap']['#attributes'] = array('class' => 'hideme'); // XML sitemap
    $form['print']['#attributes'] = array('class' => 'hideme'); // Printer, e-mail and PDF versions
    $form['path']['#attributes'] = array('class' => 'hideme'); // URL path settings
    $form['menu']['#attributes'] = array('class' => 'hideme'); // Menu settings
    // Don't forget to add this class to your template CSS file:
    // .hideme { display: none; }
  }
}

Note: There are two possible ways included to hide it from certain users. You may either restrict display by user ID (deactivated above) or by role of user (active way in above snippet). Just replace MYMODULE by your modules name and USER ROLE NAME by the name of the role which is allowed to see revision information and such collapsible fieldsets.
And don't forget to define the 'hideme' class in your templates css.

lias’s picture

Thank you very much for this code, worked great in 5.x Amadeu theme!

misanthropisht’s picture

Good work.
In my case I wanted to know if my user had one of a number of possible roles so I changed the IF condition to

  if ( !(int)array_intersect(array('AccountAdmin','Partnerl','SuperUser'), $user->roles)) 
ginc’s picture

Subscribing

phayes’s picture

Note that after implementing this, I had an issue with the position of my 'save' and 'preview' buttons. Because the hook is modifying the array, it's shuffling the order - so any form element that doesn't have weight set explicitly is going to be misplaced. The fix is to add '#weight' to the elements:

function phptemplate_node_form($form) {
  // Remove 'Log message' text area
  $form['revision_information']['#access'] = FALSE;
  $form['buttons']['#weight'] = 100;
  return drupal_render($form);
}
flamingvan’s picture

I've created a module to do this: http://drupal.org/project/removelogmessage

jayson’s picture

Thank you for the module, works like a charm!

flamingvan’s picture

Oh cool I'm glad it worked for you!

albertski’s picture

This worked for me!! :)

albertski’s picture

This worked for me!! :) Thanks raintonr
#21
Posted by raintonr on March 26, 2009 at 4:38am

Re: #1

The D6 version of this is:

<?php
function remove_log_field_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['#node']) && isset($form['revision_information']) && $form_id == $form['#node']->type .'_node_form') {
    $form['revision_information']['#access'] = FALSE;
  }
}
?>
bnadem’s picture

[quote=flamingvan]
I've created a module to do this: http://drupal.org/project/removelogmessage
[/quote]
Hi, Many thanks for the great work, but I had an issue using it ! (http://drupal.org/node/1203394)
Any suggestions please !

bnadem’s picture

Hi, Many thanks for the great work, but I had an issue using it ! (http://drupal.org/node/1203394)
Any suggestions please !

giorgio79’s picture

Version: 6.4 » 7.x-dev
Status: Closed (fixed) » Active

This "Revision information" field does not make any sense on node creation. It should be removed from node create forms in core, not in contrib modules.

marcoBauli’s picture

agree with giorgio79. Has no sense on node creation form as a "new" node is not a "revision".

Anonymous’s picture

Status: Active » Closed (works as designed)

The revision field is fine for a new node as it is the initial revision. One could add notes for why the node was created. If you don't like it you can use a hook_form_alter in custom module to hide it.

SeanBannister’s picture

Also the Jammer module allows you to remove it.

aaronbauman’s picture

jetwodru’s picture

Yes, the Log Message is really CONFUSING, I don't see the purpose of it on a Node/Create but Node/Edit, it's better to have it configurable whether to show as per content type. Thanks

drupalfan81’s picture

Issue summary: View changes

Sweet! Wish I came across this thread earlier...would have saved a lot of headache.

@Jim0203 in #18...you're the man! This worked perfectly for me. I was trying to do this by roles and using a IF statement to check if the user was in a given role. It worked, but my save/preview/delete buttons would go to the top of the page for some strange reason. So I used your method, which is basically the same thing, just in a slightly different way.

@phayes in #27, wish I saw this earlier as well, I couldn't figure out what was going on and didn't know this would fix it. Well, I went with Jim's method and it didn't move the buttons around, so I just settled with his method. But good to know this could have fixed my issue if using my code for basing it on the roles.

Great thread...got things working the way I want them to now.

chsrikiran’s picture

For D7 - to allow roles with 'View content revisions' permission can see this Revision Information field:

function CUSTOM_form_alter(&$form, &$form_state, $form_id) {
$form['revision_information']['#access'] = user_access('view revisions');
}