better_messages_before_new_thread
REQUIREMENTS
To be able to implement this guide, you need to learn how to insert PHP snippets to your website.
You can find guide here: WP Beginner
Compatibility
This action compatible with Better Messages 2.0.64 or higher
This action allows to prevent new conversation start based on custom conditions.
add_action( 'better_messages_before_new_thread', 'custom_restrict_new_thread', 10, 2 );
function custom_restrict_new_thread( &$args, &$errors ){
// User who creating thread
$user_id = get_current_user_id();
// Get array with recipients user ids, which user trying to start conversation with
$recipients = $args['recipients'];
/**
* Your logic to determine if this user can create thread
*/
$can_create_thread = false;
if( ! $can_create_thread ){
/**
* Adding error which will be shown to user
*/
$errors['uniqueErrorSlug'] = 'You cant start new thread now.';
}
}