Solved deleting posts of an account

  • Hi @baris , is there any code you can give us so that we can delete the posts by an account? (let's say user id:54321)

    Additionally, on the profile options, when I click "delete content", it actually purges the content, not deletes it. On a thread, when I "delete" a post, it just makes the post invisible but the post stays there. I think it would make more sense to say "purge content"...

  • additionally, do spiders read the content of a deleted post? do they show up on google search results?

  • NodeBB Admin

    Spiders wouldn't see deleted post content unless the spider group is given the view deleted privilege.

  • NodeBB Admin

    For deleting posts of a user something like this should work.

    /* globals require, console, process */
    'use strict';
    const nconf = require('nconf');
    	file: 'config.json',
    	base_dir: __dirname,
    	views_dir: './build/public/templates',
    	upload_path: 'public/uploads',
    const db = require('./src/database');
    const uid = '123';
    db.init(async (err) => {
    	const meta = require('./src/meta');
    	await meta.configs.init();
    	if (err) {
    		console.log(`NodeBB could not connect to your database. Error: ${err.message}`);
    	await deletePosts();
    async function deletePosts() {
    	const pids = await db.getSortedSetRange(`uid:${uid}:posts`, 0, -1);
    	const posts = require('./src/posts');
    	for (const pid of pids) {
    		await posts.delete(pid, 1);

    Replace the value of uid with the target user.

  • @baris 👍 good, I checked the moderation privileges... spiders are not given "view deleted posts" privilege...

    so, technically, from the search engine results perspective, purging the post is the same as deleting post...

  • @baris thanks for the code 👍

  • Topic has been marked as solved   crazycellsC   crazycells 

Suggested Topics

  • 20
  • 3
  • 4
  • 2
  • 5
| | | |