Paid messages for vendors only

Hello!

Let me know if we can set up a membership so that subscribers can write messages for free, and members need to purchase access to messages by paying a tariff?

Yes, it’s possible with Memberships extension, but excluding regular users from this restriction requires a code snippet. Purchasing a membership plan can enable or disable messaging.

Can you please send a code snippet?

Hi,

Please try this PHP snippet:

add_filter( 
	'hivepress/v1/components/request/context', 
	function($context) {
		if(current_user_can('edit_posts') && !isset($context['membership'])){
			$context['membership'] = ( new HivePress\Models\Membership() )->fill( ['message' => true] );
		}
		
		return $context;
	},
	1000
);
1 Like

Almost done, thanks :slight_smile:

And another question: when a user who does not have access to messages activated tries to reply to the first message, then when he clicks on the β€œSend” button, he does not see a modal window with a proposal to purchase a tariff. How to fix it?

Hi,

Please send more details that may help to detect or reproduce this issue (e.g. a link to your site, screenshots, a list of installed plugins, or the error message you get).

If the user tries to write from the β€œListings” or β€œVendors” page, then a modal window opens (picture 1)

And if you try to reply to a message in your personal account, the text with information will be displayed (picture 2).

Is it possible to make a modal window open everywhere when trying to write or send a message?

Yes, sorry for the confusion - indeed there’s no modal window on the chat page, and there’s no simple code snippet to add the modal window. Please try changing the error text to suggest navigating to the Plans page.

Tell me, how to insert a link in the error text?

Unfortunately that’s not possible yet, but we’ll allow basic HTML tags in the field labels and errors in future updates.

1 Like

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