Is there a way to delete draft .

Permalink 2 users found helpful
I'm searching a way ( by dashboard or pragramaticaly) to delete all untitled (or not) draft made by the composer ?

sebastienj
View Replies:
studio4graphics replied on at Permalink Reply
Would like to know the same thing.
ramonleenders replied on at Permalink Reply
ramonleenders
* Go to Dashboard - Sitemap
* Click on "Include System Pages in Sitemap" (or the checkbox before this text)
* Click the "+" sign before "Drafts" (only is a plus sign if you actually have drafts)
* Click the page and hit "Delete"
studio4graphics replied on at Permalink Reply
Hi, thanks for your reply.

I do know where to delete it, the problem is that you have to delete the drafts 1 at a time.
I had around 20+ drafts and wanted to delete them all together at once. (C5 version 5.6.3.3)
ramonleenders replied on at Permalink Reply
ramonleenders
Each page has an ID (cID actually). So if you want to remove them by code, you can delete them by this cID. If I'm not mistaken, this can not be done in the dashboard - removing multiple at once that is. Perhaps there's an add-on on the marketplace or someone who can make that.
MrKDilkington replied on at Permalink Reply
MrKDilkington
@sebastienj
@studio4graphics

I tried this and it works.
- it gets all the page drafts
- each page draft gets moved to the trash
$pageDrafts = Concrete\Core\Page\Page::getDrafts();
foreach ($pageDrafts as $pageDraft) {
    $pageDraft->moveToTrash();
}
studio4graphics replied on at Permalink Reply
Thank you MrKDilkington!

Going to look how to implement it in the dashboard.
MrKDilkington replied on at Permalink Reply
MrKDilkington
@studio4graphics

I am not positive about this, but I think it needs permission checks if you are going to put it into the dashboard. Otherwise any user can remove all site page drafts.
- a check to see if the user has permission to move the draft to the trash

A per user page draft removal would be even better. Users could only trash their own drafts and admins could trash all of them.
katz515 replied on at Permalink Reply
katz515