Skip to content
Docs
Get RestroPress

Filter

rpress_admin_notices

Updated
On this page

Filters the admin notices that apply to the current user.

Runs in rpress_get_admin_notices() after notices have been checked against capability, stored dismissal and condition, and sorted with problems first, then by priority. The list feeds the notification panel, its counts, the problem banner and the Dashboard card. Remove entries to hide them; an entry you add must have the same keys as a registered notice.

Available since RestroPress 3.5.1.

Parameters#

ParameterTypeDescription
$listarrayNotice arrays with keys id, kind, title, message, actions, capability, condition, dismissible, dismiss, screens and priority.

Return value#

array. Notices to show.

Example#

add_filter( 'rpress_admin_notices', 'my_hide_notices', 10, 1 );
function my_hide_notices( $list ) {
	if ( 'local' !== wp_get_environment_type() ) {
		return $list;
	}
	foreach ( $list as $index => $notice ) {
		if ( 'test_mode' === $notice['id'] ) {
			unset( $list[ $index ] );
		}
	}
	return array_values( $list );
}

Notes#

The result is cached for the request until a notice is registered or dismissed. Dismissing works from the registry, so a notice added only through this filter cannot be dismissed.

Source#

Applied in:

  • includes/features/admin-notices/loader.php (line 131), in rpress_get_admin_notices()

See also#

Was this page helpful?