Email request for sub-category

We created some sub-categories on requests.
Our client created a request for one of the sub-category but both vendors that are in different sub-categories received the email.
Is it possible to send the email for a specific sub-category and not for all the sub-category parent?


Please note that the function sends notifications to all vendors by default. If you need to search by category and other criteria, we recommend using the Search Alerts extension Search Alerts - Notify users about new listings | HivePress Extensions

​I hope this is helpful to you.

Hi Andri,
Can you tell what is the functon so I can customize it so I can only send request to that sub-category Vendors?


This is only possible using the Search Alerts extension, please check this video sample:

Hi Andrii,
I did a workaround, I deactivate the request alarm, and made one customizable.
Can you check if has any problem:

function requestUpdate($request_id, $request){

	error_log('Function requestUpdate called for RequestID: '.$request_id);

		$request_categories = $request->get_categories();
		error_log('The Category of the request is: ');

		$request_category_slug = get_term_by('name', $request_categories[0]->get_name(), 'hp_request_category')->slug;
		error_log('The request categorie slug is: '.$request_category_slug);
		// Get vendors.
		$vendors = Hivepress\Models\Vendor::query()->filter(
				'status' => 'publish',
		foreach($vendors as $vendor){
			error_log('VendorID: '.$vendor->get_id());
			// Get listings.
			$listings = Hivepress\Models\Listing::query()->filter(
					'status__in' => ['publish' ],
					'vendor'       => $vendor->get_id(),
			foreach($listings as $listing){
				$listing_categories = $listing->get_categories();
				error_log('Listing found is '.$listing->get_id().' and the category is: '.$listing_categories[0]->get_name());
				$args = [
					'taxonomy' => 'hp_listing_category',
					'name' => $listing_categories[0]->get_name(),
				$query = new WP_Term_Query($args);
				$terms = $query->get_terms();
					$terms = $terms[0];
				error_log('Listing slug is: '.$terms->slug);

				if(strcmp($request_category_slug, $terms->slug)===0){
					error_log('We found a Listing that have the same category of this Request.');
					error_log('Send email for this Vendor');

					//$requests_url = hivepress()->router->get_url( 'requests_view_page' );
					$user = $vendor->get_user();
					if ( $user ) {
						( new Hivepress\Emails\Request_Find(
								'recipient' => $user->get_email(),
								'subject'   => esc_html__( 'New Requests', 'hivepress-requests' ),

								'tokens'    => [
									'user'         => $user,
									'user_name'    => $user->get_display_name(),
									'requests_url' => get_permalink( $request->get_id() ),
						) )->send();
add_action( 'hivepress/v1/models/request/update', 'requestUpdate', 10, 2 );



Please note that we cannot debug custom code, we only provide general recommendations Support Policy | HivePress . If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work

No worries, for me is working, just for the community.

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