WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom post type, taxonomy, and role problem (6 posts)

  1. Jeff Sterup
    Member
    Posted 3 years ago #

    I have created a custom post type, a custom taxonomy, and a custom role without edit_posts capability. Because the role doesn't have the edit_posts capability the users cant add the custom taxonomy to the custom post type. The check boxes are grayed out in the post edit screen. If I give the role edit_posts capability then everything works. Below is my code for registering everything. Does anyone know how I can fix this?

    http://pastebin.com/xKq4SNk0

  2. Tim Moore
    Moderator
    Posted 3 years ago #

    I think you need to change 'capability_type' => 'coupon' to 'capability_type' => 'edit_coupons' in both the post type and taxonomy. The capabilities you are giving the user do not much what you are requiring in the post type or taxonomy.

  3. Jeff Sterup
    Member
    Posted 3 years ago #

    That broke everything. The capability_type argument is the prefix for the post_type capabilities.

  4. Jeff Sterup
    Member
    Posted 3 years ago #

    Anybody? This is frustrating.

  5. Jeff Sterup
    Member
    Posted 3 years ago #

    It looks like there is no way to do this with capabilities. I did find a way to do it though. First thing I had to do is remove the disable attribute of the checkboxes so they could be checked using jQuery. Second I have a function that gets called on the save_post hook. In that function I loop through the $_POST['tax_input']['couponbook'] variable and get the slug for each term that is checked. Last I call wp_set_object_terms to set the couponbooks that were checked. Since I've seen several people wanting to know how to do this (it should be easy to do but its not) I'm going to write a tutorial on my site explaining in detail what needs to be done and then I will come back to post a link before marking this resolved. If anyone knows an easier way to do this I would appreciate it.

  6. Jeff Sterup
    Member
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic