/bp-messages/bp-messages-functions.php

  1. <?php 
  2. /** 
  3. * BuddyPress Messages Functions. 
  4. * 
  5. * Business functions are where all the magic happens in BuddyPress. They will 
  6. * handle the actual saving or manipulation of information. Usually they will 
  7. * hand off to a database class for data access, then return 
  8. * true or false on success or failure. 
  9. * 
  10. * @package BuddyPress 
  11. * @subpackage MessagesFunctions 
  12. * @since 1.5.0 
  13. */ 
  14.  
  15. // Exit if accessed directly. 
  16. defined( 'ABSPATH' ) || exit; 
  17.  
  18. /** 
  19. * Create a new message. 
  20. * 
  21. * @since 2.4.0 Added 'error_type' as an additional $args parameter. 
  22. * 
  23. * @param array|string $args { 
  24. * Array of arguments. 
  25. * @type int $sender_id Optional. ID of the user who is sending the 
  26. * message. Default: ID of the logged-in user. 
  27. * @type int $thread_id Optional. ID of the parent thread. Leave blank to 
  28. * create a new thread for the message. 
  29. * @type array $recipients IDs or usernames of message recipients. If this 
  30. * is an existing thread, it is unnecessary to pass a $recipients 
  31. * argument - existing thread recipients will be assumed. 
  32. * @type string $subject Optional. Subject line for the message. For 
  33. * existing threads, the existing subject will be used. For new 
  34. * threads, 'No Subject' will be used if no $subject is provided. 
  35. * @type string $content Content of the message. Cannot be empty. 
  36. * @type string $date_sent Date sent, in 'Y-m-d H:i:s' format. Default: current date/time. 
  37. * @type string $error_type Optional. Error type. Either 'bool' or 'wp_error'. Default: 'bool'. 
  38. * } 
  39. * 
  40. * @return int|bool|WP_Error ID of the message thread on success, false on failure. 
  41. */ 
  42. function messages_new_message( $args = '' ) { 
  43.  
  44. // Parse the default arguments. 
  45. $r = bp_parse_args( $args, array( 
  46. 'sender_id' => bp_loggedin_user_id(),  
  47. 'thread_id' => false, // False for a new message, thread id for a reply to a thread. 
  48. 'recipients' => array(), // Can be an array of usernames, user_ids or mixed. 
  49. 'subject' => false,  
  50. 'content' => false,  
  51. 'date_sent' => bp_core_current_time(),  
  52. 'error_type' => 'bool' 
  53. ), 'messages_new_message' ); 
  54.  
  55. // Bail if no sender or no content. 
  56. if ( empty( $r['sender_id'] ) || empty( $r['content'] ) ) { 
  57. if ( 'wp_error' === $r['error_type'] ) { 
  58. if ( empty( $r['sender_id'] ) ) { 
  59. $error_code = 'messages_empty_sender'; 
  60. $feedback = __( 'Your message was not sent. Please use a valid sender.', 'buddypress' ); 
  61. } else { 
  62. $error_code = 'messages_empty_content'; 
  63. $feedback = __( 'Your message was not sent. Please enter some content.', 'buddypress' ); 
  64.  
  65. return new WP_Error( $error_code, $feedback ); 
  66.  
  67. } else { 
  68. return false; 
  69.  
  70. // Create a new message object. 
  71. $message = new BP_Messages_Message; 
  72. $message->thread_id = $r['thread_id']; 
  73. $message->sender_id = $r['sender_id']; 
  74. $message->subject = $r['subject']; 
  75. $message->message = $r['content']; 
  76. $message->date_sent = $r['date_sent']; 
  77.  
  78. // If we have a thread ID... 
  79. if ( ! empty( $r['thread_id'] ) ) { 
  80.  
  81. // ...use the existing recipients 
  82. $thread = new BP_Messages_Thread( $r['thread_id'] ); 
  83. $message->recipients = $thread->get_recipients(); 
  84.  
  85. // Strip the sender from the recipient list, and unset them if they are 
  86. // not alone. If they are alone, let them talk to themselves. 
  87. if ( isset( $message->recipients[ $r['sender_id'] ] ) && ( count( $message->recipients ) > 1 ) ) { 
  88. unset( $message->recipients[ $r['sender_id'] ] ); 
  89.  
  90. // Set a default reply subject if none was sent. 
  91. if ( empty( $message->subject ) ) { 
  92. $message->subject = sprintf( __( 'Re: %s', 'buddypress' ), $thread->messages[0]->subject ); 
  93.  
  94. // ...otherwise use the recipients passed 
  95. } else { 
  96.  
  97. // Bail if no recipients. 
  98. if ( empty( $r['recipients'] ) ) { 
  99. if ( 'wp_error' === $r['error_type'] ) { 
  100. return new WP_Error( 'message_empty_recipients', __( 'Message could not be sent. Please enter a recipient.', 'buddypress' ) ); 
  101. } else { 
  102. return false; 
  103.  
  104. // Set a default subject if none exists. 
  105. if ( empty( $message->subject ) ) { 
  106. $message->subject = __( 'No Subject', 'buddypress' ); 
  107.  
  108. // Setup the recipients array. 
  109. $recipient_ids = array(); 
  110.  
  111. // Invalid recipients are added to an array, for future enhancements. 
  112. $invalid_recipients = array(); 
  113.  
  114. // Loop the recipients and convert all usernames to user_ids where needed. 
  115. foreach ( (array) $r['recipients'] as $recipient ) { 
  116.  
  117. // Trim spaces and skip if empty. 
  118. $recipient = trim( $recipient ); 
  119. if ( empty( $recipient ) ) { 
  120. continue; 
  121.  
  122. // Check user_login / nicename columns first 
  123. // @see http://buddypress.trac.wordpress.org/ticket/5151. 
  124. if ( bp_is_username_compatibility_mode() ) { 
  125. $recipient_id = bp_core_get_userid( urldecode( $recipient ) ); 
  126. } else { 
  127. $recipient_id = bp_core_get_userid_from_nicename( $recipient ); 
  128.  
  129. // Check against user ID column if no match and if passed recipient is numeric. 
  130. if ( empty( $recipient_id ) && is_numeric( $recipient ) ) { 
  131. if ( bp_core_get_core_userdata( (int) $recipient ) ) { 
  132. $recipient_id = (int) $recipient; 
  133.  
  134. // Decide which group to add this recipient to. 
  135. if ( empty( $recipient_id ) ) { 
  136. $invalid_recipients[] = $recipient; 
  137. } else { 
  138. $recipient_ids[] = (int) $recipient_id; 
  139.  
  140. // Strip the sender from the recipient list, and unset them if they are 
  141. // not alone. If they are alone, let them talk to themselves. 
  142. $self_send = array_search( $r['sender_id'], $recipient_ids ); 
  143. if ( ! empty( $self_send ) && ( count( $recipient_ids ) > 1 ) ) { 
  144. unset( $recipient_ids[ $self_send ] ); 
  145.  
  146. // Remove duplicates & bail if no recipients. 
  147. $recipient_ids = array_unique( $recipient_ids ); 
  148. if ( empty( $recipient_ids ) ) { 
  149. if ( 'wp_error' === $r['error_type'] ) { 
  150. return new WP_Error( 'message_invalid_recipients', __( 'Message could not be sent because you have entered an invalid username. Please try again.', 'buddypress' ) ); 
  151. } else { 
  152. return false; 
  153.  
  154. // Format this to match existing recipients. 
  155. foreach ( (array) $recipient_ids as $i => $recipient_id ) { 
  156. $message->recipients[ $i ] = new stdClass; 
  157. $message->recipients[ $i ]->user_id = $recipient_id; 
  158.  
  159. // Bail if message failed to send. 
  160. $send = $message->send(); 
  161. if ( false === is_int( $send ) ) { 
  162. if ( 'wp_error' === $r['error_type'] ) { 
  163. if ( is_wp_error( $send ) ) { 
  164. return $send; 
  165. } else { 
  166. return new WP_Error( 'message_generic_error', __( 'Message was not sent. Please try again.', 'buddypress' ) ); 
  167.  
  168. return false; 
  169.  
  170. /** 
  171. * Fires after a message has been successfully sent. 
  172. * 
  173. * @since 1.1.0 
  174. * 
  175. * @param BP_Messages_Message $message Message object. Passed by reference. 
  176. */ 
  177. do_action_ref_array( 'messages_message_sent', array( &$message ) ); 
  178.  
  179. // Return the thread ID. 
  180. return $message->thread_id; 
  181.  
  182. /** 
  183. * Send a notice. 
  184. * 
  185. * @param string $subject Subject of the notice. 
  186. * @param string $message Content of the notice. 
  187. * @return bool True on success, false on failure. 
  188. */ 
  189. function messages_send_notice( $subject, $message ) { 
  190. if ( !bp_current_user_can( 'bp_moderate' ) || empty( $subject ) || empty( $message ) ) { 
  191. return false; 
  192.  
  193. // Has access to send notices, lets do it. 
  194. } else { 
  195. $notice = new BP_Messages_Notice; 
  196. $notice->subject = $subject; 
  197. $notice->message = $message; 
  198. $notice->date_sent = bp_core_current_time(); 
  199. $notice->is_active = 1; 
  200. $notice->save(); // Send it. 
  201.  
  202. /** 
  203. * Fires after a notice has been successfully sent. 
  204. * 
  205. * @since 1.0.0 
  206. * 
  207. * @param string $subject Subject of the notice. 
  208. * @param string $message Content of the notice. 
  209. */ 
  210. do_action_ref_array( 'messages_send_notice', array( $subject, $message ) ); 
  211.  
  212. return true; 
  213.  
  214. /** 
  215. * Deletes message thread(s) for a given user. 
  216. * 
  217. * Note that "deleting" a thread for a user means removing it from the user's 
  218. * message boxes. A thread is not deleted from the database until it's been 
  219. * "deleted" by all recipients. 
  220. * 
  221. * @since 2.7.0 The $user_id parameter was added. Previously the current user 
  222. * was always assumed. 
  223. * 
  224. * @param int|array $thread_ids Thread ID or array of thread IDs. 
  225. * @param int $user_id ID of the user to delete the threads for. Defaults 
  226. * to the current logged-in user. 
  227. * @return bool True on success, false on failure. 
  228. */ 
  229. function messages_delete_thread( $thread_ids, $user_id = 0 ) { 
  230.  
  231. if ( empty( $user_id ) ) { 
  232. $user_id = bp_loggedin_user_id(); 
  233.  
  234. /** 
  235. * Fires before specified thread IDs have been deleted. 
  236. * 
  237. * @since 1.5.0 
  238. * @since 2.7.0 The $user_id parameter was added. 
  239. * 
  240. * @param int|array $thread_ids Thread ID or array of thread IDs to be deleted. 
  241. * @param int $user_id ID of the user the threads are being deleted for. 
  242. */ 
  243. do_action( 'messages_before_delete_thread', $thread_ids, $user_id ); 
  244.  
  245. if ( is_array( $thread_ids ) ) { 
  246. $error = 0; 
  247. for ( $i = 0, $count = count( $thread_ids ); $i < $count; ++$i ) { 
  248. if ( ! BP_Messages_Thread::delete( $thread_ids[$i], $user_id ) ) { 
  249. $error = 1; 
  250.  
  251. if ( ! empty( $error ) ) { 
  252. return false; 
  253.  
  254. /** 
  255. * Fires after specified thread IDs have been deleted. 
  256. * 
  257. * @since 1.0.0 
  258. * @since 2.7.0 The $user_id parameter was added. 
  259. * 
  260. * @param int|array Thread ID or array of thread IDs that were deleted. 
  261. * @param int ID of the user that the threads were deleted for. 
  262. */ 
  263. do_action( 'messages_delete_thread', $thread_ids, $user_id ); 
  264.  
  265. return true; 
  266. } else { 
  267. if ( ! BP_Messages_Thread::delete( $thread_ids, $user_id ) ) { 
  268. return false; 
  269.  
  270. /** This action is documented in bp-messages/bp-messages-functions.php */ 
  271. do_action( 'messages_delete_thread', $thread_ids, $user_id ); 
  272.  
  273. return true; 
  274.  
  275. /** 
  276. * Check whether a user has access to a thread. 
  277. * 
  278. * @param int $thread_id ID of the thread. 
  279. * @param int $user_id Optional. ID of the user. Default: ID of the logged-in user. 
  280. * @return int|null Message ID if the user has access, otherwise null. 
  281. */ 
  282. function messages_check_thread_access( $thread_id, $user_id = 0 ) { 
  283. if ( empty( $user_id ) ) { 
  284. $user_id = bp_loggedin_user_id(); 
  285.  
  286. return BP_Messages_Thread::check_access( $thread_id, $user_id ); 
  287.  
  288. /** 
  289. * Mark a thread as read. 
  290. * 
  291. * Wrapper for {@link BP_Messages_Thread::mark_as_read()}. 
  292. * 
  293. * @param int $thread_id ID of the thread. 
  294. * 
  295. * @return false|int Number of threads marked as read or false on error. 
  296. */ 
  297. function messages_mark_thread_read( $thread_id ) { 
  298. return BP_Messages_Thread::mark_as_read( $thread_id ); 
  299.  
  300. /** 
  301. * Mark a thread as unread. 
  302. * 
  303. * Wrapper for {@link BP_Messages_Thread::mark_as_unread()}. 
  304. * 
  305. * @param int $thread_id ID of the thread. 
  306. * 
  307. * @return false|int Number of threads marked as unread or false on error. 
  308. */ 
  309. function messages_mark_thread_unread( $thread_id ) { 
  310. return BP_Messages_Thread::mark_as_unread( $thread_id ); 
  311.  
  312. /** 
  313. * Set messages-related cookies. 
  314. * 
  315. * Saves the 'bp_messages_send_to', 'bp_messages_subject', and 
  316. * 'bp_messages_content' cookies, which are used when setting up the default 
  317. * values on the messages page. 
  318. * 
  319. * @param string $recipients Comma-separated list of recipient usernames. 
  320. * @param string $subject Subject of the message. 
  321. * @param string $content Content of the message. 
  322. */ 
  323. function messages_add_callback_values( $recipients, $subject, $content ) { 
  324. @setcookie( 'bp_messages_send_to', $recipients, time() + 60 * 60 * 24, COOKIEPATH, COOKIE_DOMAIN, is_ssl() ); 
  325. @setcookie( 'bp_messages_subject', $subject, time() + 60 * 60 * 24, COOKIEPATH, COOKIE_DOMAIN, is_ssl() ); 
  326. @setcookie( 'bp_messages_content', $content, time() + 60 * 60 * 24, COOKIEPATH, COOKIE_DOMAIN, is_ssl() ); 
  327.  
  328. /** 
  329. * Unset messages-related cookies. 
  330. * 
  331. * @see messages_add_callback_values() 
  332. */ 
  333. function messages_remove_callback_values() { 
  334. @setcookie( 'bp_messages_send_to', false, time() - 1000, COOKIEPATH, COOKIE_DOMAIN, is_ssl() ); 
  335. @setcookie( 'bp_messages_subject', false, time() - 1000, COOKIEPATH, COOKIE_DOMAIN, is_ssl() ); 
  336. @setcookie( 'bp_messages_content', false, time() - 1000, COOKIEPATH, COOKIE_DOMAIN, is_ssl() ); 
  337.  
  338. /** 
  339. * Get the unread messages count for a user. 
  340. * 
  341. * @param int $user_id Optional. ID of the user. Default: ID of the logged-in user. 
  342. * @return int 
  343. */ 
  344. function messages_get_unread_count( $user_id = 0 ) { 
  345. if ( empty( $user_id ) ) { 
  346. $user_id = bp_loggedin_user_id(); 
  347.  
  348. return BP_Messages_Thread::get_inbox_count( $user_id ); 
  349.  
  350. /** 
  351. * Check whether a user is the sender of a message. 
  352. * 
  353. * @param int $user_id ID of the user. 
  354. * @param int $message_id ID of the message. 
  355. * @return int|null Returns the ID of the message if the user is the 
  356. * sender, otherwise null. 
  357. */ 
  358. function messages_is_user_sender( $user_id, $message_id ) { 
  359. return BP_Messages_Message::is_user_sender( $user_id, $message_id ); 
  360.  
  361. /** 
  362. * Get the ID of the sender of a message. 
  363. * 
  364. * @param int $message_id ID of the message. 
  365. * @return int|null The ID of the sender if found, otherwise null. 
  366. */ 
  367. function messages_get_message_sender( $message_id ) { 
  368. return BP_Messages_Message::get_message_sender( $message_id ); 
  369.  
  370. /** 
  371. * Check whether a message thread exists. 
  372. * 
  373. * @param int $thread_id ID of the thread. 
  374. * @return int|null The message thread ID on success, null on failure. 
  375. */ 
  376. function messages_is_valid_thread( $thread_id ) { 
  377. return BP_Messages_Thread::is_valid( $thread_id ); 
  378.  
  379. /** 
  380. * Get the thread ID from a message ID. 
  381. * 
  382. * @since 2.3.0 
  383. * 
  384. * @param int $message_id ID of the message. 
  385. * @return int The ID of the thread if found, otherwise 0. 
  386. */ 
  387. function messages_get_message_thread_id( $message_id = 0 ) { 
  388. global $wpdb; 
  389.  
  390. $bp = buddypress(); 
  391.  
  392. return (int) $wpdb->get_var( $wpdb->prepare( "SELECT thread_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) ); 
  393.  
  394. /** Messages Meta *******************************************************/ 
  395.  
  396. /** 
  397. * Delete metadata for a message. 
  398. * 
  399. * If $meta_key is false, this will delete all meta for the message ID. 
  400. * 
  401. * @since 2.2.0 
  402. * 
  403. * @see delete_metadata() for full documentation excluding $meta_type variable. 
  404. * 
  405. * @param int $message_id ID of the message to have meta deleted for. 
  406. * @param string|bool $meta_key Meta key to delete. Default false. 
  407. * @param string|bool $meta_value Meta value to delete. Default false. 
  408. * @param bool $delete_all Whether or not to delete all meta data. 
  409. * 
  410. * @return bool True on successful delete, false on failure. 
  411. */ 
  412. function bp_messages_delete_meta( $message_id, $meta_key = false, $meta_value = false, $delete_all = false ) { 
  413. // Legacy - if no meta_key is passed, delete all for the item. 
  414. if ( empty( $meta_key ) ) { 
  415. global $wpdb; 
  416.  
  417. $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->messagemeta} WHERE message_id = %d", $message_id ) ); 
  418.  
  419. // With no meta_key, ignore $delete_all. 
  420. $delete_all = false; 
  421. } else { 
  422. $keys = array( $meta_key ); 
  423.  
  424. $retval = false; 
  425.  
  426. // No keys, so stop now! 
  427. if ( empty( $keys ) ) { 
  428. return $retval; 
  429.  
  430. add_filter( 'query', 'bp_filter_metaid_column_name' ); 
  431.  
  432. foreach ( $keys as $key ) { 
  433. $retval = delete_metadata( 'message', $message_id, $key, $meta_value, $delete_all ); 
  434.  
  435. remove_filter( 'query', 'bp_filter_metaid_column_name' ); 
  436.  
  437. return $retval; 
  438.  
  439. /** 
  440. * Get a piece of message metadata. 
  441. * 
  442. * @since 2.2.0 
  443. * 
  444. * @see get_metadata() for full documentation excluding $meta_type variable. 
  445. * 
  446. * @param int $message_id ID of the message to retrieve meta for. 
  447. * @param string $meta_key Meta key to retrieve. Default empty string. 
  448. * @param bool $single Whether or not to fetch all or a single value. 
  449. * @return mixed 
  450. */ 
  451. function bp_messages_get_meta( $message_id, $meta_key = '', $single = true ) { 
  452. add_filter( 'query', 'bp_filter_metaid_column_name' ); 
  453. $retval = get_metadata( 'message', $message_id, $meta_key, $single ); 
  454. remove_filter( 'query', 'bp_filter_metaid_column_name' ); 
  455.  
  456. return $retval; 
  457.  
  458. /** 
  459. * Update a piece of message metadata. 
  460. * 
  461. * @since 2.2.0 
  462. * 
  463. * @see update_metadata() for full documentation excluding $meta_type variable. 
  464. * 
  465. * @param int $message_id ID of the message to have meta deleted for. 
  466. * @param string|bool $meta_key Meta key to update. 
  467. * @param string|bool $meta_value Meta value to update. 
  468. * @param string $prev_value If specified, only update existing metadata entries with 
  469. * the specified value. Otherwise, update all entries. 
  470. * @return mixed 
  471. */ 
  472. function bp_messages_update_meta( $message_id, $meta_key, $meta_value, $prev_value = '' ) { 
  473. add_filter( 'query', 'bp_filter_metaid_column_name' ); 
  474. $retval = update_metadata( 'message', $message_id, $meta_key, $meta_value, $prev_value ); 
  475. remove_filter( 'query', 'bp_filter_metaid_column_name' ); 
  476.  
  477. return $retval; 
  478.  
  479. /** 
  480. * Add a piece of message metadata. 
  481. * 
  482. * @since 2.2.0 
  483. * 
  484. * @see add_metadata() for full documentation excluding $meta_type variable. 
  485. * 
  486. * @param int $message_id ID of the message to have meta deleted for. 
  487. * @param string|bool $meta_key Meta key to update. 
  488. * @param string|bool $meta_value Meta value to update. 
  489. * @param bool $unique Whether the specified metadata key should be 
  490. * unique for the object. If true, and the object 
  491. * already has a value for the specified metadata key,  
  492. * no change will be made. 
  493. * @return mixed 
  494. */ 
  495. function bp_messages_add_meta( $message_id, $meta_key, $meta_value, $unique = false ) { 
  496. add_filter( 'query', 'bp_filter_metaid_column_name' ); 
  497. $retval = add_metadata( 'message', $message_id, $meta_key, $meta_value, $unique ); 
  498. remove_filter( 'query', 'bp_filter_metaid_column_name' ); 
  499.  
  500. return $retval; 
  501.  
  502. /** Email *********************************************************************/ 
  503.  
  504. /** 
  505. * Email message recipients to alert them of a new unread private message. 
  506. * 
  507. * @since 1.0.0 
  508. * 
  509. * @param array|BP_Messages_Message $raw_args { 
  510. * Array of arguments. Also accepts a BP_Messages_Message object. 
  511. * @type array $recipients User IDs of recipients. 
  512. * @type string $email_subject Subject line of message. 
  513. * @type string $email_content Content of message. 
  514. * @type int $sender_id User ID of sender. 
  515. * } 
  516. */ 
  517. function messages_notification_new_message( $raw_args = array() ) { 
  518. if ( is_object( $raw_args ) ) { 
  519. $args = (array) $raw_args; 
  520. } else { 
  521. $args = $raw_args; 
  522.  
  523. // These should be extracted below. 
  524. $recipients = array(); 
  525. $email_subject = $email_content = ''; 
  526. $sender_id = 0; 
  527.  
  528. // Barf. 
  529. extract( $args ); 
  530.  
  531. if ( empty( $recipients ) ) { 
  532. return; 
  533.  
  534. $sender_name = bp_core_get_user_displayname( $sender_id ); 
  535.  
  536. // Send an email to each recipient. 
  537. foreach ( $recipients as $recipient ) { 
  538. if ( $sender_id == $recipient->user_id || 'no' == bp_get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) ) { 
  539. continue; 
  540.  
  541. // User data and links. 
  542. $ud = get_userdata( $recipient->user_id ); 
  543. if ( empty( $ud ) ) { 
  544. continue; 
  545.  
  546. $unsubscribe_args = array( 
  547. 'user_id' => $recipient->user_id,  
  548. 'notification_type' => 'messages-unread',  
  549. ); 
  550.  
  551. $args = array( 
  552. 'tokens' => array( 
  553. 'usermessage' => wp_strip_all_tags( stripslashes( $message ) ),  
  554. 'message.url' => esc_url( bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() . '/view/' . $thread_id . '/' ),  
  555. 'sender.name' => $sender_name,  
  556. 'usersubject' => sanitize_text_field( stripslashes( $subject ) ),  
  557. 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),  
  558. ),  
  559. ); 
  560. bp_send_email( 'messages-unread', $ud, $args ); 
  561.  
  562. /** 
  563. * Fires after the sending of a new message email notification. 
  564. * 
  565. * @since 1.5.0 
  566. * @deprecated 2.5.0 Use the filters in BP_Email. 
  567. * $email_subject and $email_content arguments unset and deprecated. 
  568. * 
  569. * @param array $recipients User IDs of recipients. 
  570. * @param string $email_subject Deprecated in 2.5; now an empty string. 
  571. * @param string $email_content Deprecated in 2.5; now an empty string. 
  572. * @param array $args Array of originally provided arguments. 
  573. */ 
  574. do_action( 'bp_messages_sent_notification_email', $recipients, '', '', $args ); 
  575. add_action( 'messages_message_sent', 'messages_notification_new_message', 10 ); 
.