How Can We Help?

Control if user can start new thread with hooks

You are here:
< All Topics

With this filter you can control who can start new thread dynamically and you can also left custom message.

add_action( 'bp_better_messages_before_new_thread', 'restrict_new_thread_function', 10, 2 );
function restrict_new_thread_function( &$args, &$errors ){
    // User who creating thread
    $user_id = get_current_user_id();

    /**
     * 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.';
    }
}
Table of Contents