Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
You are absolutely the best! I'm going to create a simple plugin from your code. –  maisdesign Mar 11 '12 at 15:08
add comment
  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.

share|improve this answer
    
Thank you very much for your effort but @helenhousandi answer is better :P –  maisdesign Mar 11 '12 at 15:09
add comment

Your Answer

 
discard

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.