messages_check_thread_access

Check whether a user has access to a thread.

Description

(int|null) messages_check_thread_access( (int) $thread_id, (int) $user_id = 0 ); 

Returns (int|null)

Message ID if the user has access, otherwise null.

Parameters (2)

0. $thread_id (int)
ID of the thread.
1. $user_id — Optional. (int)
ID of the user. Default: ID of the logged-in user.

Usage

  1. if ( !function_exists( 'messages_check_thread_access' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-messages/bp-messages-functions.php'; 
  3.  
  4. // ID of the thread. 
  5. $thread_id = -1; 
  6.  
  7. // Optional. ID of the user. Default: ID of the logged-in user. 
  8. $user_id = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = messages_check_thread_access($thread_id, $user_id); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-messages/bp-messages-functions.php  
  1. function messages_check_thread_access( $thread_id, $user_id = 0 ) { 
  2. if ( empty( $user_id ) ) { 
  3. $user_id = bp_loggedin_user_id(); 
  4.  
  5. return BP_Messages_Thread::check_access( $thread_id, $user_id );