0

I have created a custom post type called Alerts. I want Editor users to be able to have full permissions to publish and edit alerts. I copied all of the capabilities of an administrator to satisfy this requirement. Yet, the having all capabilities for my custom post type has removed permission to publish altogether, which is unexpected. Here is my custom post type configuration. What am I doing wrong that is removing capabilities to publish and edit the alerts?

        register_post_type('alert', array(
        'label'     => 'Alerts',
        'public'    => true,
        'capability_type' => 'alert',
        'capabilities'  => array(
            'delete_others_pages'       => 'delete_others_pages',
            'delete_others_posts'       => 'delete_others_posts',
            'delete_pages'              => 'delete_pages',
            'delete_posts'              => 'delete_posts',
            'delete_private_pages'      => 'delete_private_pages',
            'delete_private_posts'      => 'delete_private_posts',
            'delete_published_pages'    => 'delete_published_pages',
            'delete_published_posts'    => 'delete_published_posts',
            'edit_others_pages'         => 'edit_others_pages',
            'edit_others_posts'         => 'edit_others_posts',
            'edit_pages'                => 'edit_pages',
            'edit_posts'                => 'edit_posts',
            'edit_private_pages'        => 'edit_private_pages',
            'edit_private_posts'        => 'edit_private_posts',
            'edit_published_pages'      => 'edit_published_pages',
            'edit_published_posts'      => 'edit_published_posts',
            'publish_pages'             => 'publish_pages',
            'publish_posts'             => 'publish_posts',
            'read_private_pages'        => 'read_private_pages',
            'read_private_posts'        => 'read_private_posts',
            'read'                      => 'read',
            'activate_plugins'          => 'activate_plugins',
            'edit_dashboard'            => 'edit_dashboard',
            'edit_theme_options'        => 'edit_theme_options',
            'export'                    => 'export',
            'import'                    => 'import',
            'list_users'                => 'list_users',
            'manage_categories'         => 'manage_categories',
            'manage_links'              => 'manage_links',
            'manage_options'            => 'manage_options',
            'moderate_comments'         => 'moderate_comments',
            'promote_users'             => 'promote_users',
            'remove_users'              => 'remove_users',
            'switch_themes'             => 'switch_themes',
            'upload_files'              => 'upload_files',
            'customize'                 => 'customize',
            'delete_site'               => 'delete_site'
        )
    ));

1 Answer 1

1

You should map CPT capabilities with the capability_type This way can WP understand what you want to do. Try edit_$cap_type (where $cap_type = alert)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.