WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would need to simplify the "upload new image" interface for our Authors : basically, hide a few fields that will only confuse my wordpress "authors" (like the "Description" and "Alt" text inputs). Administrators and Editors need to see these, though.

How can i implement that hiding/showing inputs according to the user's priviledges?

share|improve this question
up vote 2 down vote accepted

You will need to hook into attachment_fields_to_edit and unset them for a role.

You can use current_user_can('author') http://codex.wordpress.org/Function_Reference/current_user_can

Example to remove image alt field

function remove_caption($form_fields) {

  if (current_user_can('author')){
   $form_fields['image_alt']['input'] = 'hidden';
   return $form_fields;
add_filter('attachment_fields_to_edit','remove_caption', 15, 2);

My initial post used unset but I tried it and it did not work, from the example in this post: How can I remove fields in the attachment editor? , not sure why, instead the example above works using hidden.

share|improve this answer
Excellent, thanks a lot! For the record, i've published a broader function with more options so that others don't have to look °-) pixeline.be/blog/development/… – pixeline Aug 13 '11 at 8:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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