WordPress.org

Ready to get started?Download WordPress

Forums

How can I prevent authors from changing custom post type fields? (5 posts)

  1. danromanchik
    Member
    Posted 1 year ago #

    I've created a WP site with a membership database using a custom post type. There is a post for each member than contains information about the member. When a user signs up, the site admin creates a WP user for that member and makes the new user the author of the corresponding post. This way, the member can update his or her membership info.

    The problem is that there is some fields--such as the expiration date--that I don't want the member to be able to edit. So, I'm trying to figure out how to remove those fields from the edit screen, much the same way remove_post_type_support() removes the title, editor, etc. from the edit screen?

    Can anyone give me a clue as how to do this?

    Thanks, Dan

  2. CPC Mike
    Member
    Posted 1 year ago #

    Try this:

    http://wordpress.org/extend/plugins/user-role-editor/

    I have never used it but I do know that it allows you to add custom capabilities. Their website has a pretty good breakdown of how to use it:

    http://shinephp.com/user-role-editor-wordpress-plugin/

  3. danromanchik
    Member
    Posted 1 year ago #

    Thanks for the reply, CedarPoint, but this plugin isn't going to do it. I already have a plugin to edit the role capabilities, but what I need is even finer control. I need to be able to control whether or not particular fields show up on the edit screen. These plugins just don't do that.

  4. CPC Mike
    Member
    Posted 1 year ago #

    This plugin can set an access level to custom fields. You may not want to use it but you should be able to get some insight from the code how it is done. Sorry I can't be of more help as I misread your original post.

    http://wordpress.org/extend/plugins/custom-field-template/

  5. bcworkz
    Member
    Posted 1 year ago #

    If the fields are in a meta box, you can wrap the field code in a if current user can block in the box's callback function.

    if (current_user_can('edit_user')) {
      echo '<input type="text" id="myplugin_expiration_field" name="myplugin_expiration_field" value="whatever" size="25">';
    }

    Unless the user has the proper capability, the field will not display.

Topic Closed

This topic has been closed to new replies.

About this Topic