Products still available in search results if the vendor is deleted

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Marketplace (WooCommerce Multivendor Marketplace) Products still available in search results if the vendor is deleted

Viewing 1 reply thread
  • Author
    Posts
    • #119115
      milad_tai
      Participant

      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).

    • #119312

      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.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.