• Hello

    I’ve created few taxonomies with CPTUI and I wanted to specify capabilities for them, so I did it like this :

    function notes_customize_taxonomy($args, $taxonomy_slug)
    {
        // These would already be used as default value, but providing as an example.
        // $taxonomy_slug parameter would be the slug of the taxonomy currently being registered.
        $args['capabilities'] = array(
            'manage_terms' => "manage_categories",
            'edit_terms' => "manage_categories",
            'delete_terms' => "manage_categories",
            'assign_terms' => "edit_posts",
        );
    
        return $args;
    }
    add_filter('cptui_pre_register_taxonomy', 'notes_customize_taxonomy', 10, 2);

    So I imagined that if a user have the permission “edit_posts” he can assign a term to a post, but not create a new one on that taxonomy.

    But, in the create_item_permissions_check method, it’s not like this :

    if ( ( is_taxonomy_hierarchical( $this->taxonomy )
                && ! current_user_can( $taxonomy_obj->cap->edit_terms ) )
            || ( ! is_taxonomy_hierarchical( $this->taxonomy )
                && ! current_user_can( $taxonomy_obj->cap->assign_terms ) ) )

    The capablility tested is different if the taxonomy is hierarchical or not.
    Why ?

    Is this realy what is wanted ?

    Thanks for your answers.

    • This topic was modified 6 years, 1 month ago by Jan Dembowski. Reason: Moved to Developing with WordPress, this is not an Everything else WordPress topic

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘WP_REST_Terms_Controller::create_item_permissions_check seems weird to me’ is closed to new replies.