Hiding reply option for unclaimed listings

Hello, is there a feature to deactivate replies only for listings that are not yet claimed. I think this would be a great incentive to actually claim a listing. It would also be a good measure against fraud, as only claimed and verified listings can receive replies.

Yes, this may be possible with a simple code snippet, I’ll pass this to another developer and he’ll check if there’s a simple solution for this.

This would be awesome :rose::rose:

Here is a simple solution for hiding replies in not verified listings.

add_filter('hivepress/v1/templates/listing_view_page/blocks', 'disable_reply_button', 1000, 2);
add_filter('hivepress/v1/templates/listing_view_block/blocks', 'disable_reply_button', 1000, 2);

function disable_reply_button($blocks, $template) {
	$listing = $template->get_context('listing');

	if (!$listing || $listing->get_verified()) {
		return $blocks;
	}

	hivepress()->template->fetch_blocks($blocks, ['message_send_link'], true);

	return $blocks;
}

Thank you :rose::rose::rose:
Where do I have to add that?

Works like a charm, I used the Code Snippet Plugin

2 Likes

Could there also be a simple code snippet that works like this for verified vendors? That would be awesome!

Yes, you can use the snippet code below. He disables the reply button not verified vendors.

add_filter('hivepress/v1/templates/vendor_view_page/blocks', 'disable_reply_button', 1000, 2);
add_filter('hivepress/v1/templates/vendor_view_block/blocks', 'disable_reply_button', 1000, 2);

function disable_reply_button($blocks, $template) {
	$vendor = $template->get_context('vendor');

	if (!$vendor || $vendor->get_verified()) {
		return $blocks;
	}

	hivepress()->template->fetch_blocks($blocks, ['message_send_link'], true);

	return $blocks;
}

Thanks Vasiliy but code snippets returns with an error on line 5?

Can you share a screenshot or text error?

Sure…

The snippet has been deactivated due to an error on line 5:

Cannot redeclare function disable_reply_button

You’ve used the previous snippet from this topic. Then is an error because we have two functions with the same names. Please use this (updated) snippet below.

add_filter('hivepress/v1/templates/vendor_view_page/blocks', 'disable_vendor_reply_button', 1000, 2);
add_filter('hivepress/v1/templates/vendor_view_block/blocks', 'disable_vendor_reply_button', 1000, 2);

function disable_vendor_reply_button($blocks, $template) {
	$vendor = $template->get_context('vendor');
	
	if (!$vendor || $vendor->get_verified()) {
		return $blocks;
	}

	hivepress()->template->fetch_blocks($blocks, ['message_send_link'], true);

	return $blocks;
}
1 Like

All done, that’s perfect. Thanks for your help.

Hi, I just realized that there is another button to contact the vendor which is near the profile pic. Is there a way to hide it for listings that are not yet claimed as well?

The code you send last time only hides the Reply to Listing button:

add_filter('hivepress/v1/templates/listing_view_page/blocks', 'disable_reply_button', 1000, 2);
add_filter('hivepress/v1/templates/listing_view_block/blocks', 'disable_reply_button', 1000, 2);

function disable_reply_button($blocks, $template) {
	$listing = $template->get_context('listing');

	if (!$listing || $listing->get_verified()) {
		return $blocks;
	}

	hivepress()->template->fetch_blocks($blocks, ['message_send_link'], true);

	return $blocks;
}

Good day, here is a code snippet to hide all reply buttons on the not verified listing pages.

add_filter('hivepress/v1/templates/listing_view_page/blocks', 'disable_reply_button', 1000, 2);
add_filter('hivepress/v1/templates/listing_view_block/blocks', 'disable_reply_button', 1000, 2);

function disable_reply_button($blocks, $template) {
	$listing = $template->get_context('listing');

	if (!$listing || $listing->get_verified()) {
		return $blocks;
	}

	hivepress()->template->fetch_blocks($blocks, ['message_send_link'], true);

	add_filter('hivepress/v1/templates/vendor_view_page/blocks', 'disable_vendor_reply_button', 1000);
	add_filter('hivepress/v1/templates/vendor_view_block/blocks', 'disable_vendor_reply_button', 1000);

	return $blocks;
}

function disable_vendor_reply_button($blocks) {
	hivepress()->template->fetch_blocks($blocks, ['message_send_link'], true);

	return $blocks;
}