Disable authoring information and other fieldsets
jakeg - January 6, 2006 - 14:02
If you want to hide authoring information and the other fieldsets on new/edit node pages, add something like this to a module. It seems to work, but please reply if anyone's got a better solution.
You'll need to change 'news_article_node_form' to e.g. 'page_node_form' or whatever your node type is. Alternatively if you want it for all node types.
<?php
// Implementation of hook_form_alter
function news_article_form_alter($form_id, &$form) {
if ($form_id == 'news_article_node_form') {
// We're going to hide various fields by setting default values for them
$form['author']['#type'] = 'value';
$form['author']['name'] = array('#type'=>'value', '#value'=>$form['author']['name']['#default_value']);
$form['author']['date'] = array('#type'=>'value', '#value'=>$form['author']['date']['#default_value']);
$form['options']['#type'] = 'value';
$form['options']['status'] = array('#type'=>'value', '#value'=>$form['options']['status']['#default_value']);
$form['options']['moderate'] = array('#type'=>'value', '#value'=>$form['options']['moderate']['#default_value']);
$form['options']['promote'] = array('#type'=>'value', '#value'=>$form['options']['promote']['#default_value']);
$form['options']['sticky'] = array('#type'=>'value', '#value'=>$form['options']['sticky']['#default_value']);
$form['options']['revisions'] = array('#type'=>'value', '#value'=>$form['options']['revisions']['#default_value']);
$form['user_comments']['#type'] = 'value';
$form['user_comments']['comment'] = array('#type'=>'value', '#value'=>$form['user_comments']['comment']['#default_value']);
$form['menu']['#type'] = 'value';
}
}
?>
I just tried this on a
I just tried this on a flexinode but I couldn't get it to work.
I pasted this on line 617 of the flexinode.module:
// Implementation of hook_form_alter
function flexinode_form_alter($form_id, &$form) {
if ($form_id == 'flexinode_form') {
// We're going to hide various fields by setting default values for them
$form['author']['#type'] = 'value';
$form['author']['name'] = array('#type'=>'value', '#value'=>$form['author']['name']['#default_value']);
$form['author']['date'] = array('#type'=>'value', '#value'=>$form['author']['date']['#default_value']);
$form['options']['#type'] = 'value';
$form['options']['status'] = array('#type'=>'value', '#value'=>$form['options']['status']['#default_value']);
$form['options']['moderate'] = array('#type'=>'value', '#value'=>$form['options']['moderate']['#default_value']);
$form['options']['promote'] = array('#type'=>'value', '#value'=>$form['options']['promote']['#default_value']);
$form['options']['sticky'] = array('#type'=>'value', '#value'=>$form['options']['sticky']['#default_value']);
$form['options']['revisions'] = array('#type'=>'value', '#value'=>$form['options']['revisions']['#default_value']);
$form['user_comments']['#type'] = 'value';
$form['user_comments']['comment'] = array('#type'=>'value', '#value'=>$form['user_comments']['comment']['#default_value']);
$form['menu']['#type'] = 'value';
}
}
Just below the * Implementation of hook_form(). info
Is this the best place to put and do we need to set the values to true/false
change if ($form_id == 'flexinode_form') {
to
if ($form_id == 'flexinode_node_form') {
and that'll work.
You think this is the only way?
It seems someone should put an option somewhere to disable these fieldsets. You find a better way yet?
You can administer this for
You can administer this for anonymous and authenticated users in access control page. Normally only the user number 1 see all the fieldsets.
Solution for Drupal 5?
As this does not seem to work with Drupal 5:
Does anybody know how to hide (particularly) the Authoring information field?
Cheers,
Makkus
Possbile Solution for Drupal 5
For Drupal 5:
I just commented out the following chunk of code in modules/node/node.module and the authoring field didn't show up
<?php
// Node author information for administrators
$form['author'] = array(
'#type' => 'fieldset',
'#access' => user_access('administer nodes'),
'#title' => t('Authoring information'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 20,
);
$form['author']['name'] = array('#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#default_value' => $node->name ? $node->name : '', '#weight' => -1, '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))));
$form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, '#description' => t('Format: %time. Leave blank to use the time of form submission.', array('%time' => $node->date)));
if (isset($node->nid)) {
$form['author']['date']['#default_value'] = $node->date;
}
?>
It should be in function node_form($node, $form_values = NULL)
If there is another direct way, I'm unaware of it.
The more elegant solution
The more elegant solution was posted here:
http://drupal.org/node/109917
this works for me in 5.x
remove fieldsets from node add/edit forms
<?phphook_form_alter($form_id, &$form)
{
switch ($form_id) {
case 'modulename_node_form':
unset($form['author']);//remove authoring
unset($form['menu']);//remove menu options
unset($form['options']);//remove publishing options
unset($form['comment_settings']);//remove comment settings
unset($form['path']);//remove url path settings (if path module is enabled)
unset($form['log']);//log box
unset($form['body_filter']['filter']);//remove input format
}
}
?>
@ depace: where did you put
@ depace: where did you put this?
and if you disable "administer nodes" it is not possible to delete nodes anymore - right?
but how to hide all this stuff (wonderful would be per contenttype) with the possibility to delete nodes (minimum own nodes)?
thanks and greetings
momper
RE: Hiding extra elements
The following function worked for me. Put it in template.php
<?php
/**
* Change the node form
*/
function phptemplate_node_form($form) {
// echo "<div style='direction:ltr;'>"; dprint_r ($form); echo '</div>';
// Hide 'Log message' text area
$form['log']['#access'] = FALSE;
// Hide the author collapsable box
$form['author']['#access'] = FALSE;
// Hide the publishing options collapsable box
$form['options']['#access'] = FALSE;
// Open the file attachments collapsible block in a full state
$form['attachments']['#collapsed'] = FALSE;
return drupal_render($form);
}
?>
Amnon
-
Professional: Drupal Israel | Drupal Development & Consulting
Personal: Hitech Dolphin: Regain Simple Joy :)
NO NEED TO HACK THIS!
Commenter bilgehan (above) is right. It's a simple permission issue.
User1 will always see all fieldsets on add/edit node pages. But if you'd like to hide that extra stuff (Authoring Information, Publishing Options, etc.) from other users, go to /admin/user/access and de-select the "administer nodes" permission (found under 'node module') for anyone who doesn't need to see/act upon these extra fieldsets.
Disabling the authrizing information
no need go for coding just do this
Go to Admin > Site Building > Themes > Configure. You'll see checkboxes that allow you to disable authoring information.
Disabling the authrizing information
Thanks its work.
A new module comming soon
For those interested, I've create a module for my own personal use, which lets you set each individual option under the Authoring information and Publishing options sections of the
node editpage.At the moment, the module only sets these permissions globally and they apply to all content types.
Once I get approved for a CVS account, I'll contribute my module, and see about adding more features to it, such as choosing which content types the settings apply to, or maybe even a 'per content type permissions' functionality.
Anyways, just wanted to let you guys know that something IS coming, so stay tuned.
P.S. The module was written for Drupal 5.x
Is module comming out soon?
Is module comming out soon? :-) can i get some beta relase, if you say it's working ok i would like to use it/test it :-)
send to marko@deepsun.net
thanx
formfilter
maybe this is interesting in general to:
http://drupal.org/project/formfilter
Display post information on
I landed here trying find out how to remove the "post information" from a Webforms form. Doesn't seem like that's what this thread is about actually but just in case someone else lands here with the same question I had, all you have to do is goto Themes->Configure->Global Settings and uncheck the box for Webform under "Display post information on."
formdefaults did the trick
This module: formdefaults did the trick for me about hiding the authoring and other fields in the drupal forms :)
please look at this code for disabling authorinfo fields
This is working for me (drupal 6)
function hook_form_alter($form)
{
$form['author']['#access'] = FALSE; // for disabling the author info
$form['options']['#access'] = FALSE; // for disabling the publishing option settings
$form['menu']['#access'] = FALSE;// for disabling the menu settings
$form['comment_settings']['#access'] = FALSE;// for disabling the comment settings
$form['path']['#access'] = FALSE;// for disabling the URL path settings
}
Thanks&Regards
Madipally Naveeen Kumar
formfilter module is all you
formfilter module is all you ever need for this, its perfect.
hi, any chance to disable
hi, any chance to disable just a parts of the "options"? I mean "Promoted on front page"
$form['options']['promote']['#access'] = FALSE; // for disabling the publishing option settings
does not work
same question like czeky
same question like czeky
Try this .Its working for
Try this .Its working for me.
$form['options']['#type'] = 'value';
$form['options']['status'] = array('#type'=>'value', '#value'=>$form['options']['status']['#default_value']);
$form['options']['moderate'] = array('#type'=>'value', '#value'=>$form['options']['moderate']['#default_value']);
$form['options']['promote'] = array('#type'=>'value', '#value'=>$form['options']['promote']['#default_value']);
$form['options']['sticky'] = array('#type'=>'value', '#value'=>$form['options']['sticky']['#default_value']);