How to hide a button from non-registered people

Is there a snippet code to hide this WhatsApp button from the unregistered public?

I’ve found this:

But it doesn’t work

add_filter(
	'hivepress/v1/models/listing/attributes',
	function( $attributes ) {
		if ( isset( $attributes['whatsapp'] ) && !is_user_logged_in() ) {
			$attributes['whatsapp']['display_format'] = 'Login to view';
		}
 
		return $attributes;
	},
	1000
);
add_filter(
	'hivepress/v1/fields/phone',
	function( $attributes ) {
		if ( isset( $attributes['phone'] ) && !is_user_logged_in() ) {
			$attributes['phone']['###########'] = '#user_login_modal';
		}
 
		return $attributes;
	},
	1000
);

Hi,

Please try to use this CSS snippet, we have not tested it, so it is only a suggestion: body:not(.logged-in) .hp-listing__attribute–field-name-here {display:none}

​I hope this is helpful to you.

I actually found a solution thanks to your code; I finally hid the entire seller profile from those who are not connected.

body:not(.logged-in) .hp-vendor--view-block {display:none}

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