bp_messages_is_message_starred

Function to determine if a message ID is starred.

Description

bp_messages_is_message_starred( (int) $mid = 0, (int) $user_id = 0 ); 

Parameters (2)

0. $mid — Optional. (int)
The message ID. Please note that this isn't the message thread ID.
1. $user_id — Optional. (int)
The user id.

Usage

  1. if ( !function_exists( 'bp_messages_is_message_starred' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-messages/bp-messages-star.php'; 
  3.  
  4. // The message ID. Please note that this isn't the message thread ID. 
  5. $mid = -1; 
  6.  
  7. // The user id. 
  8. $user_id = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_messages_is_message_starred($mid, $user_id); 
  12.  

Defined (1)

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

/bp-messages/bp-messages-star.php  
  1. function bp_messages_is_message_starred( $mid = 0, $user_id = 0 ) { 
  2. if ( empty( $user_id ) ) { 
  3. $user_id = bp_loggedin_user_id(); 
  4.  
  5. if ( empty( $mid ) ) { 
  6. return false; 
  7.  
  8. $starred = array_flip( (array) bp_messages_get_meta( $mid, 'starred_by_user', false ) ); 
  9.  
  10. if ( isset( $starred[$user_id] ) ) { 
  11. return true; 
  12. } else { 
  13. return false;