3

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?

2

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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