• Resolved Jeff Sterup

    (@foomagoo)


    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?

    https://pastebin.com/xKq4SNk0

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    Thread Starter Jeff Sterup

    (@foomagoo)

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

    Thread Starter Jeff Sterup

    (@foomagoo)

    Anybody? This is frustrating.

    Thread Starter Jeff Sterup

    (@foomagoo)

    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.

    Thread Starter Jeff Sterup

    (@foomagoo)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom post type, taxonomy, and role problem’ is closed to new replies.