Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Saurabh Jain

    (@saurabhj91)

    Hi @dualcube,

    Is there anything? please let me know.

    Thread Starter Saurabh Jain

    (@saurabhj91)

    Hi @dualcube,

    I am using this code if anyone need the same.

    //delete user data when user is deleted
    add_action('delete_user', 'my_delete_user');
    function my_delete_user($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);
        }
    }

    Hello @saurabhj91
    Where did you place that code? Can it be converted to a plugin?
    Thanks for sharing, its very important!
    Have a good day

    Thread Starter Saurabh Jain

    (@saurabhj91)

    Hi @tomaccoman,

    I have placed this code in functions.php.

    It can be converted into the plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove Vendor Products’ is closed to new replies.