Control if user can reply to thread with hooks

You are here:
< All Topics

With this filter you can control who can reply to the thread dynamically and you can also left custom message if needed.

add_filter( 'bp_better_messages_can_send_message', function($allowed, $user_id, $thread_id){
    $is_restricted = true;

    if( $is_restricted ) {
        $allowed = false;

        /**
         * With this global variable you can add extra message which will replace editor field
         */
        global $bp_better_messages_restrict_send_message;
        $bp_better_messages_restrict_send_message['your_unique_error_slug'] = 'You cant reply to this thread';

    }

    return $allowed;
}, 10, 3);

This is the example of blocked thread:

Previous Adding additional fields to new thread
Next Control if user can start new thread with hooks
Table of Contents