• Hello,

    first of all: we have lifetime licence, but dont know how to open a ticket in other way like here. Its a big project allready launched, we really need help in this case. We can arrange a paid session if possible, its urgent.

    We have many custom post types and our simple goal is to enable/disable granular rights (for example delete) for each post type (and custom post type) separately. After enabling the custom post types capabilities (code below), we can see in “Roles” many new checkboxes for the custom post types – and we can check/uncheck them separately. In “Admin Menu” the custom post type is visible as well and checked. So far everything looks fine.

    Problem: It doesnt matter if we check/uncheck any of the rights in “Roles”. The options delete, edit, etc do not show up anymore in Backend for the user role.

    Cheers, Daniel

    Our custom post type code, example from post type “gvp_accordion”:

    function gvp_accordion()
    {
        register_post_type(
            'gvp_accordion',
            array(
                'labels' => array(
                    'name' => __('Accordions', 'gvp'),
                    'singular_name' => __('Accordion', 'gvp'),
                ),
                'taxonomies' => array('gvp_accordion_category'),
                'rewrite' => array('slug' => 'accordion'),
                'public' => true,
                'has_archive' => true,
                'show_ui' => true,
                'publicly_queryable' => true,
                'supports' => array(
                    'title',
    
                ),
                'capability_type' => 'gvp_accordion',
                'capabilities' => array(
                    'publish_posts' => 'publish_gvp_accordions',
                    'edit_posts' => 'edit_gvp_accordions',
                    'edit_others_posts' => 'edit_others_gvp_accordions',
                    'edit_private_posts' => 'edit_private_gvp_accordions',
                    'delete_posts' => 'delete_gvp_accordions',
                    'delete_others_posts' => 'delete_others_gvp_accordions',
                    'delete_private_posts' => 'delete_private_gvp_accordions',
                    'read_private_posts' => 'read_private_gvp_accordions',
                    'edit_post' => 'edit_gvp_accordion',
                    'delete_post' => 'delete_gvp_accordion',
                    'read_post' => 'read_gvp_accordion',
                )
            )
        );
    }
    add_action('init', 'gvp_accordion');
    
    
    
    • This topic was modified 1 year, 1 month ago by Danielson79.
    • This topic was modified 1 year, 1 month ago by Danielson79.
Viewing 4 replies - 1 through 4 (of 4 total)
  • You just need to add “map_meta_cap” => true

    best regards
    andreas from moving-bytes.at

    Plugin Author Janis Elsts

    (@whiteshadow)

    I’m not very familiar with how CPTs work internally, but that seems like a good suggestion to try.

    Another thing I would recommend is to try not overriding meta capabilities like edit_post. That is, get rid of these three lines:

    'edit_post' => 'edit_gvp_accordion',
    ?'delete_post' => 'delete_gvp_accordion',
    ?'read_post' => 'read_gvp_accordion',

    Finally, a note: www.remarpro.com forum rules do not allow developers to use these forums to provide support for paid plugins, so in the future, please use this contact form if you have a question that’s specifically about the Pro version of the plugin. (I think your current post might be fine here since, at its core, it’s not really about the plugin – either free or paid version – but about the technicalities of creating custom post types.)

    Thread Starter Danielson79

    (@danielson79)

    Thank you very much for your fast replies – first test was successful for 1 post type. We will check more tonight.

    The permissions have to be given via Tab ‘admin Menu’ within ‘edit permissions’ popup. So the Tab ‘Roles’ is useless for this case or at least it still doesnt matter, what we check/uncheck there.

    Cheers
    Daniel


    Plugin Author Janis Elsts

    (@whiteshadow)

    The “Roles” tab can be useful if the CPT is configured accordingly (and the admin menu can “Permissions” popup can override “Roles” settings in a limited way, so you may get unexpected results if you try to change both at once). However, that topic is specifically about the Pro version of the plugin, so we won’t be able to investigate it further here.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Post Types’ is closed to new replies.