Free Directory, Listing & Classifieds WordPress Plugin Support Extensions Messages Allow only Contributor to Message

Allow only Contributor to Message

  • Author
    Posts
  • unitehearts

    Hi
    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

    ihordeveloper

    You can try adding this one:

    add_filter(
    	'hivepress/v1/models/message/errors',
    	function( $errors, $message ) {
    		if ( ! $message->get_id() && empty( $errors ) && ! current_user_can( 'edit_posts' ) ) {
    			$errors[] = 'error text here';
    		}
    
    		return $errors;
    	},
    	10,
    	2
    );

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

    unitehearts

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

    ihordeveloper

    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.

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

You must be logged in to reply to this topic.

Subscribe

Sign In

Don't have an account? Register

Forgot password?

Register

Already have an account? Sign In

Forgot password?

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.