Ending call dynamically (WebSocket version)

This example of function which allow to end the currently ongoing call dynamically $thread_id = 34; $message = "Your call is end"; //Additional message to show to users (leave empty to not show message) BP_Better_Messages()->premium->endCall( $thread_id, $message );

Read more

Control if user can make audio/video call with hooks

add_filter('bp_better_messages_can_audio_call', 'disable_calls', 10, 3); add_filter('bp_better_messages_can_video_call', 'disable_calls', 10, 3); function disable_calls( $can_call, $user_id, $thread_id ){     if( ! $can_call ) return $can_call;          $user = get_userdata($user_id); $allowed_roles = (array)['administrator', 'other_role'];     $user_roles = (array) $user->roles; $is_allowed…

Read more

Control if user can start new thread with hooks

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(); /** *…

Read more

Making custom messages notification counter

Sometimes you need to create custom unread messages counter at your website. This is example of jQuery code snippet to make counter display messages count dynamically: <script type="text/javascript"> jQuery(document).on('bp-better-messages-update-unread', function( event ) { var unread = parseInt(event.originalEvent.detail.unread); if( isNaN (…

Read more

Control if user can reply to thread with hooks

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…

Read more

How to replace email notifications with custom layout?

This is example of code which help you to overwrite email notifications template add_filter('bp_better_messages_overwrite_email', 'override_messages_emailer', 10, 4); function override_messages_emailer( $bool, $user_id, $thread_id, $messages ){ $gmt_offset = get_option('gmt_offset') * 3600; /** * Get user which will receive email */ $user =…

Read more

How to add welcome message for new users?

This snippet will add welcome message on user register at your website. function bp_messages_welcome_message( $user_id = false, $key = false, $user = false ){ if ( ! function_exists( 'BP_Better_Messages' ) ) return false; $args = array( 'sender_id' => 1, 'thread_id'…

Read more
0