Join our new community forum for support & discussion

Join Now

Home Support Extensions Messages Allow only Contributor to Message

Allow only Contributor to Message

  • Author
  • unitehearts

    I would like to restrict messaging to only those who have posted their own Listing – can you give some code snippet for this.
    Thank you very much

    ihor developer

    You can try adding this one:

    	function( $errors, $message ) {
    		if ( ! $message->get_id() && empty( $errors ) && ! current_user_can( 'edit_posts' ) ) {
    			$errors[] = 'error text here';
    		return $errors;

    But it doesn’t hide the message buttons, only checks the submitted messages.


    this is nice. is it possible that this error can be made to popup before one types and submits the Message

    ihor developer

    Sorry, but customizations are not part of the HivePress support, although I’m always glad to help if there’s a simple fix. If you’re familiar with PHP please try customizing the message button.


    this snippet does not seem to work now. it asks for login – and the login modal pops up.
    please help

    ihor developer

    It worked this way since the initial version – if the current user is not logged in there will be a login modal on click (it also works this way for Favorites and other actions that require login). Once the user is logged in the snippet suggested above should work fine.


    Thanks Ihor this code is working.
    Can you guide on a small tweak. Suppose someone posts an Ad and then later deletes it or hides it, they are still a Contributor and can send messages.

    How to alter the code to ensure that unless a person has a live ad, they cannot send a message.

    ihor developer

    Sorry, this requires further customizations (to update the user role if the last of the user’s listings is deleted or hidden).


    Hey Ihor,

    this works great. Can you edit the snippet so that this works only in specific categories? Like in Category A only contributor can messeage but in Category B everyone can message the vendor?

    ihor developer

    Unfortunately there’s no simple code snippet for this since messages are not always linked to a listing (only when a message is sent via the listing page).

Viewing 10 posts - 1 through 10 (of 10 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.