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

Add an admin notice to the BP queue.

Description

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

$notice

(string) (Optional) The notice you are adding to the queue.

Default value: ''

$type

(string) (Optional) The notice type; optional. Usually either "updated" or "error".

Default value: 'updated'

Source

File: bp-core/admin/bp-core-admin-functions.php

function bp_core_add_admin_notice( $notice = '', $type = 'updated' ) {

	// Do not add if the notice is empty.
	if ( empty( $notice ) ) {
		return;
	}

	// Double check the object before referencing it.
	if ( ! isset( buddypress()->admin->notices ) ) {
		buddypress()->admin->notices = array();
	}

	// Add the notice.
	buddypress()->admin->notices[] = array(
		'message' => $notice,
		'type'    => $type,
	);
}

Changelog

Changelog
Version Description
BuddyPress 1.5.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.