Delete old comments from a page

This script will delete all comments from a page that are more than 1 year old.

number page = getPage("CTR", "Delete old comments from a page"); //get page

//get all comments from page
number [] allComm = getAllCommentIds(page);
interval year = "365d";

//loop through all comments
for(number c in allComm) {
    //get additional info about comment
	CComment comm = getCommentById(c);


	//check age of comment
    if(comm.created < (currentDate - year)) {
        //delete comment if older than 1 year
		deleteComment(c);
    }
}

return "done";

See Other Recipes

See More Documentation