Change listing status when vendor is not active

Hi

Is there a code reference or a solution to put automatically all the vendor’s listings to “Draft” when vendor profile is changed/set to “Pending review”.

Currently if I disable the vendor profile then all his listings are still visible which is not good in my opinion.

Thanks in advance!

Please try this PHP snippet. But please note that it can require further customization and testing. If you are not familiar with the code customization, then please consider hiring someone for custom work https://fvrr.co/32e7LvY

add_action(
	'hivepress/v1/models/vendor/update_status',
	function($vendor_id, $new_status, $old_status, $vendor){
		if('pending' !== $new_status){
			return;
		}
		
		$listings = \HivePress\Models\Listing::query()->filter(['vendor' => $vendor_id])->get();
		
		foreach($listings as $listing){
			$listing->set_status('draft')->save_status();
		}
	},
	1000,
	4
);
1 Like

Thanks, I’ll check!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.