forks!
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.
register_post_type('zonas', array( '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" => [ "title" ] ) );
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; }