0

I have a multi author blog, I want to restrict authors from adding custom fields with a particular key.

For example I dont want authors to edit or add the custom field "rating"

3
  • 1
    when i work on a multi author blog, i remove the custom fields meta box and add a new one with my own options that way i can control what is shown to whom. – Bainternet Jan 24 '11 at 19:05
  • how to remove the custom fields box? – Satish Gandham Jan 24 '11 at 20:26
  • remove_meta_box( 'postcustom','post','normal' ); – Bainternet Jan 25 '11 at 6:24
1

The way I would approach this is:

  1. Create a custom field with an underscore in front of it - Example: _rating this way it doesn't show up in the normal custom field interface
  2. Create a meta box that manages this custom field
  3. Wrap your add_meta_box function with if(current_user_can('administrator'))

This will only create the meta box if a user is an administrator. It's not a fireproof method unless you disable the custom field interface.

If this is a plugin you can use remove_meta_box if the user is not an administrator before the post edit page renders.

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.