Hide Vendor information from logged-out visitors

Hi there,

I need to be able to hide certain Vendor information from logged out visitors to the site.
I’ve tried to use this snippet without success (I still see the Vendor’s phone number on their account profile page):

add_filter(
	'hivepress/v1/models/vendor/attributes',
	function( $attributes ) {
		if ( isset( $attributes['vendor-phone-number'] ) && !is_user_logged_in() ) {
			$attributes['vendor-phone-number']['display_format'] = 'Login to view';
		}
 
		return $attributes;
	},
	1000
);

What am I doing wrong?

Hi,

Sorry, there’s no simple code snippet for this, it would require a custom implementation. As a workaround, you can use the Memberships extension: Memberships - Charge users for viewing listings | HivePress Extensions

That’s strange because I got this snippet from one of your colleagues who advised another user to use it. The only change I made was replacing ‘listing’ with ‘vendor’ in the ‘hivepress/v1/models/vendor/attributes’ string.

Here is where I got the snippet from: How can i hide contact details to the logged out users? - #2 by yevhen