Serch1 (@serch1)

Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • @serch1

    Participant

    Sorry for the thread up, but hope there is a function by default to delete all user posts at bbpress forums. Someone know what function is?

    Thanks a lot in advance.

    @serch1

    Participant

    Well, what I want in wordpress is:

    
    add_action('delete_user', 'delete_posts_and_attachments');
    function delete_posts_and_attachments($user_id) {
        $args = array (
            'numberposts' => -1,
            'post_type' => 'any',
            'author' => $user_id
        );
        // get all posts by this user: posts, pages, attachments, etc..
        $user_posts = get_posts($args);
    
        if (empty($user_posts)) return;
    
        // delete all the user posts
        foreach ($user_posts as $user_post) {
            wp_delete_post($user_post->ID, true);
        }
    }

    But where and how can I delete posts from bbpress? any help will be appreciated :\

    @serch1

    Participant

    Hello Robkk! Thanks a lot for your detailed suggestion. I know this way to delete users from wordpress backend, but I’m looking for the function who does this in order to add a little code to my bbpress frontend 🙂

Viewing 3 replies - 1 through 3 (of 3 total)