bp_core_add_admin_notice

Add an admin notice to the BP queue.

Description

bp_core_add_admin_notice( (string) $notice = '', (string) $type = 'updated' ); 

Messages added with this function are displayed in BuddyPress's general purpose admin notices box. It is recommended that you hook this function to admin_init, so that your messages are loaded in time.

Parameters (2)

0. $notice — Optional. (string) => ''
The notice you are adding to the queue.
1. $type — Optional. (string) => 'updated'
The notice type; optional. Usually either updated or error..

Usage

  1. if ( !function_exists( 'bp_core_add_admin_notice' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/admin/bp-core-admin-functions.php'; 
  3.  
  4. // The notice you are adding to the queue. 
  5. $notice = ''; 
  6.  
  7. // The notice type; optional. Usually either "updated" or "error". 
  8. $type = 'updated'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_core_add_admin_notice($notice, $type); 
  12.  

Defined (1)

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

/bp-core/admin/bp-core-admin-functions.php  
  1. function bp_core_add_admin_notice( $notice = '', $type = 'updated' ) { 
  2.  
  3. // Do not add if the notice is empty. 
  4. if ( empty( $notice ) ) { 
  5. return; 
  6.  
  7. // Double check the object before referencing it. 
  8. if ( ! isset(buddypress)->admin->notices ) ) { 
  9. buddypress)->admin->notices = array(); 
  10.  
  11. // Add the notice. 
  12. buddypress)->admin->notices[] = array( 
  13. 'message' => $notice,  
  14. 'type' => $type,  
  15. );