views:

27

answers:

3

Hi! I am using hook_form_alter to disable some publishing options whet authors adds or edits the nodes:

/**
 * hook_form_alter ()
 */
function mymodule_form_alter(&$form, $form_state, $form_id) {
  global $user;

if ($form['#id'] == 'node-form') {

    unset($form['comment_settings']);
    unset($form['path']);
    unset($form['revision_information']);
    unset($form['author']);
  }
  } 

However - I can not find (even in debugger) what variable to unset to disable Input Format options to prevent users from changing default format. Do you other way to do that?

A: 

Disable "administer filters" permission works but it feels kind of cruel.

Lukasz
A: 

HOOK_FORM_ALTER will work if we make sure our hook is being called after filter_form_alter (or hook from any other module altering form). This is being done by setting our module weight in drupal system table to be bigger than others we compete with. It is usually done in hook_install:

db_query("UPDATE {system} SET weight = [yournumber] WHERE name = 'yourmodulename'");

Drupal uses weight field to determine order or calling hooks.

Taken from: http://drupal.org/node/110238

Hope it will help someone.

Lukasz
+1  A: 

Hm, why dont you just set up your filter formats so that normal users dont have more than one, and simply remove the administer filters permission from everyone, that's not 'cruel' that's called 'secure'.

chx
Hmm.. I am not sure it it works as I need at least 2 different input formats (bloggers can use wysiwig editor, which needs full html format to add blogs, etc...) but for instance - adding a comments needs to be in simple filtered html format.
Lukasz