bp_core_add_notification

Add a notification for a specific user, from a specific component.

Description

(boolean) bp_core_add_notification( (string) $item_id, (int) $user_id, (string) $component_name, (string) $component_action, (int) $secondary_item_id = 0, (constant) $date_notified = false, (int) $is_new = 1 ); 

Returns (boolean)

True on success, false on failure.

Parameters (7)

0. $item_id (string)
The item id.
1. $user_id (int)
The user id.
2. $component_name (string)
The component name.
3. $component_action (string)
The component action.
4. $secondary_item_id — Optional. (int)
The secondary item id.
5. $date_notified — Optional. (constant) => false
The date notified.
6. $is_new — Optional. (int) => 1
The is new.

Usage

  1. if ( !function_exists( 'bp_core_add_notification' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/deprecated/1.9.php'; 
  3.  
  4. // The item id. 
  5. $item_id = ''; 
  6.  
  7. // The user id. 
  8. $user_id = -1; 
  9.  
  10. // The component name. 
  11. $component_name = ''; 
  12.  
  13. // The component action. 
  14. $component_action = ''; 
  15.  
  16. // The secondary item id. 
  17. $secondary_item_id = -1; 
  18.  
  19. // The date notified. 
  20. $date_notified = false; 
  21.  
  22. // The is new. 
  23. $is_new = 1; 
  24.  
  25. // NOTICE! Understand what this does before running. 
  26. $result = bp_core_add_notification($item_id, $user_id, $component_name, $component_action, $secondary_item_id, $date_notified, $is_new); 
  27.  

Defined (1)

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

/bp-core/deprecated/1.9.php  
  1. function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = 0, $date_notified = false, $is_new = 1 ) { 
  2.  
  3. // Bail if notifications is not active 
  4. if ( ! bp_is_active( 'notifications' ) ) { 
  5. return false; 
  6.  
  7. // Trigger the deprecated function notice 
  8. _deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_add_notification()' ); 
  9.  
  10. // Notifications must always have a time 
  11. if ( false === $date_notified ) { 
  12. $date_notified = bp_core_current_time(); 
  13.  
  14. // Add the notification 
  15. 'item_id' => $item_id,  
  16. 'user_id' => $user_id,  
  17. 'component_name' => $component_name,  
  18. 'component_action' => $component_action,  
  19. 'secondary_item_id' => $secondary_item_id,  
  20. 'date_notified' => $date_notified,  
  21. 'is_new' => $is_new 
  22. ) );