0

What I would like to know is if it is possible to disable the edit post function in wordpress based on User's roles. I try to explain better. Let's take an 'Editor' as role example: I would like Editors, Authors.... but NOT ADMIN to be able to write posts only using Custom Fields instead of the 'classic' built in edit post function of WordPress.

Is there anyone who knows how to do it (maybe it is only a sentence or 2 in functions.php) or who as/know a plugin that will let me do it?

Thank you very much!

2 Answers 2

2

You can remove post type support for the editor on a conditional basis. The following should work:

add_action( 'add_meta_boxes', 'wpse45113_remove_editor' );
function wpse45113_remove_editor() {
    // change the capability and post type to whatever is appropriate
    if ( ! current_user_can( 'install_plugins' ) )
        remove_post_type_support( 'post', 'editor' );
}

I'm using add_meta_boxes because it fires not too long before the editor is initialized, but there are a number of hooks that would also work. You can similarly only add the meta box with the custom fields for those users within the same if block.

1
  • You are absolutely the best! I'm going to create a simple plugin from your code.
    – maisdesign
    Commented Mar 11, 2012 at 15:08
0
  1. You'll maybe want to use some Plugin to add a Custom Post Type.
  2. Then you can take another plugin to add custom fields.
  3. Last but not least, you could use a plugin like Members to allow some roles access to the CPT or deny it.

I can't give you any other plugin recommendations, as it a) depends on your needs and b) I'm not that much on the repo and used to code stuff myself.

1
  • Thank you very much for your effort but @helenhousandi answer is better :P
    – maisdesign
    Commented Mar 11, 2012 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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