Serch1 (@serch1)

Forum Replies Created

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

  • Serch1
    Participant

    @serch1

    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

    @serch1

    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

    @serch1

    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)