Join 3,512 readers in helping fund MetaFilter (Hide)


How do I get rid of extra options when adding Drupal content?
October 15, 2009 7:11 AM   Subscribe

Drupal question: Is it possible to get rid of all those unnecessary options (Input Format, Menu Settings, Book Outline, Revision Information, URL Path Settings, etc.) that confront users when they're trying to create new content?

I've created a custom content type on my Drupal site and it works fine. But I'm concerned that users who click on "Create Content" will be confused by all these options, which they don't have permission to edit anyway. Other than CSS-ing them out, is there any way to get rid of them for a certain level of user?

And please let me know if this question is confusing. Drupal seems to lend itself to mind-bending confusion.
posted by miriam to Computers & Internet (14 answers total) 6 users marked this as a favorite
 
Yes, create a module and use hook_form_alter to unset() the things you don't want out of the form array.
posted by meta_eli at 7:53 AM on October 15, 2009


That's a bit of overkill. Just set those DIVs to display:none via the theme CSS.
posted by Setec Astronomy at 7:58 AM on October 15, 2009


Are you checking the forms when you're logged in as the target user? Many of the fields that the user doesn't have permissions to edit won't appear to them, but you will see them when logged in as an administrator.

Besides the CSS approach you mentioned, a module could handle this, as meta_eli mentions. I had a quick search and found the Formfilter module which seems to offer what you're looking for. I can't claim to have used it myself though.
posted by Gomez_in_the_South at 7:59 AM on October 15, 2009


Thanks for the answer. Is it necessary to create a module in order to use hook_form_alter?
posted by miriam at 7:59 AM on October 15, 2009


ARGH. ME NO READ QUESTION WELL ENOUGH.

Certain things will show for certain permission levels. You can't just train users to ignore those? CSS no good?
posted by Setec Astronomy at 7:59 AM on October 15, 2009


Oh, thanks for both answers. Sorry, didn't preview. Yes, the unnecessary fields seem to show up regardless of which permissions the user has. I'm going to go check out the Formfilter module -- that sounds promising.
posted by miriam at 8:01 AM on October 15, 2009


Geez, I really have to start previewing. Yes, I can order my users to ignore these fields in the documentation, but it seems to be a pretty common source of confusion and irritation to uninitiated users. CSS is OK, but it seems kind of like throwing the baby out with the bathwater.
posted by miriam at 8:03 AM on October 15, 2009


I would create a module and use hook_form_alter(). It is really quite easy. It will be something like 5 lines of code. I can send you an example of a similar module we use, if you'd like.


And "train users to ignore those" ? Wow, you must have much better users than I do :)
posted by meta_eli at 8:05 AM on October 15, 2009


Can they still see those options if you remove their privs to create that kind of content?
posted by valadil at 8:06 AM on October 15, 2009


meta_eli, if you'd be willing to send me that example, I'd really appreciate it. Even if I end up using Formfilter, I'd really like to know how to do this in the future.

And, yes, the options seem to show up regardless of the user's privileges.

Thanks!
posted by miriam at 8:08 AM on October 15, 2009


If you can, I'd recommend creating the module as meta_eli suggests, I know it's daunting thinking of creating your own module, but making a basic module isn't too difficult. It will also come in useful to achieve other things in the future which can be done a lot more quickly (or easily) via a module than through other methods.
posted by Gomez_in_the_South at 8:15 AM on October 15, 2009


And "train users to ignore those" ? Wow, you must have much better users than I do :)

OK, that was pie-in-the-sky, I admit it.

I continue to be amazed by the users who cannot read a single line of documentation, but scrutinize every obscure option when submitting a story. Just hit the !)(%!@)( submit button!
posted by Setec Astronomy at 8:16 AM on October 15, 2009


Sure, here's a snippet from a module we've named fiercecommon (so the file is fiercecommon.module). You'll also need a corresponding .info file to get Drupal to recognize it. Note that this is Drupal 5, I think the function will look a little different for Drupal 6.

I highly recommend reading Pro Drupal Development, by the way. Very well written.
posted by meta_eli at 9:31 AM on October 15, 2009


I suspect you just put your list of examples up quickly, without necessarily checking each one, but I'm going to pick a few nits for the benefit of future readers. This assumes that you are running a Drupal 6.x site:

Input Format is something you don't want to hide if, in fact, the user has more than one option. You can prevent them from having more than one option by changing the settings at admin/settings/filters, so that the role(s) they belong to can use only one format.

Menu Settings will not show up unless they have permission to administer menus.

Book Outline will not show up unless they have permission to administer book outlines.

URL Path Settings will not show up unless they have permission to create url aliases.

Revision Information will not show up unless they have permission to administer nodes, which your rank-and-file user should definitely not have.
posted by bricoleur at 9:31 AM on October 15, 2009 [1 favorite]


« Older hi guys...this question is pre...   |  Cold weather makes me cry-- li... Newer »
This thread is closed to new comments.