Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Products still available in search results if the vendor is deleted
Tagged: search, vendor items
- This topic has 1 reply, 2 voices, and was last updated 4 years, 8 months ago by Sarmistha Chakraborty.
Viewing 1 reply thread
- AuthorPosts
- April 14, 2020 at 9:35 pm #119115milad_taiParticipant
Items/products that has been created in the search result by searching the vendor, won’t be deleted after the vendor is deleted or got a lower rank (e.g. Customer).
- April 15, 2020 at 2:12 pm #119312Sarmistha ChakrabortyMember
Hello,
By-default when you delete the vendor/author then product will not deleted, the vendor’s products goes to “draft” status.
If you want delete vendor’s product if the vendor is deleted,Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/add_action('delete_user', 'my_delete_user'); function my_delete_user($user_id) { if(wcfm_is_vendor($user_id)) { $args = array ( 'numberposts' => -1, 'post_type' => 'product', //for all posts by this user: posts, pages, attachments, etc.. use post_type => "any" 'author' => $user_id ); $user_posts = get_posts($args); if (empty($user_posts)) return; foreach ($user_posts as $user_post) { wp_delete_post($user_post->ID, true); } } }
Thanks.
- AuthorPosts
Viewing 1 reply thread
- You must be logged in to reply to this topic.