Well, I’m developing a plugin with a custom post type and I need create a front end page with form who allow a custom role (create by third part plugin) create and delete my custom post. But, I receive a not allow delete error alert.

Register CPT.

        'labels'      => array(
            'name'          => __('Zonas de treino'),
            'singular_name' => __('Zona de treino'),
        'public'      => true,
        'has_archive' => true,
        'rewrite'     => ["slug" => "zonas"],
        "menu_position" => 120, 
        'capabilities' => array(
            'edit_post'          => 'edit_zonas', 
            'read_post'          => 'read_zonas', 
            'delete_post'        => 'delete_zonas', 
            'edit_posts'         => 'edit_zonas', 
            'edit_others_posts'  => 'edit_others_zonas', 
            'publish_posts'      => 'publish_zonas',       
            'read_private_posts' => 'read_private_zonas', 
            'create_posts'       => 'edit_zonas', 
            'delete_published_posts' => 'delete_published_zonas'
        "menu_icon"     => "dashicons-clock",
        "supports"      => [

Function to generate delete link (works with administrator role)

function wp_delete_post_link($link = 'Excluir', $before = '', $after = '', $post) {    
    $link = "".$link."";
    echo $before . $link . $after;

1 Answer 1


Look at line 63 of the code https://developer.wordpress.org/reference/functions/map_meta_cap/

If you don't provide a specific post, it is not allowed.

Your code is mixing meta capabilities with primitive capabilities. (yours are all plural or primitive)

"Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts', 'edit_others_posts', etc.

The meta capability uses the object to make it into a primitive, but if you don't pass it in the link, how can it be used?

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.