#56296 closed defect (bug) (invalid)
is_network_admin() function does not work correctly on multisite
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Administration | Keywords: | reporter-feedback |
| Focuses: | multisite | Cc: |
Description
I'm trying to execute this simple function on a wordpress 6.0 multisite:
function network_admin_check() {
if ( is_network_admin() ) {
echo __( 'You are viewing a WordPress network administration page', 'textdomain' );
} else {
echo __( 'You are not viewing a WordPress network administration page', 'textdomain' );
}
}
add_action( 'admin_init', 'network_admin_check');
Reference: https://developer.wordpress.org/reference/functions/is_network_admin/
It partially works. I want to show a message when I'm in website.com/wp-admin/network/ but it only works on the else condition, example when I'm in a subsite backend like website.com/de/wp-admin it shows the message "You are not viewing a WordPress network administration page".
Change History (5)
#3
in reply to:
↑ 2
@
4 years ago
Replying to johnbillion:
Thanks for the report @stefanowp2021 and welcome to WordPress Trac. I'm unable to reproduce this problem on a fresh installation of WordPress Multisite. The
is_network_admin()function is working as expected in the network admin area.
Can you confirm whether the problem persists if you deactivate your plugins and switch to a default theme such as Twenty Twenty One? Don't forget to check for any plugins in
wp-content/mu-pluginsor awp-content/sunrise.phpfile too.
Hi John,
I've tried on another wordpress installation and it works ok for me too.
I need to investigate further to fix the issue.
We can close this ticket considering is not a wordpress bug. Thank you.
Thanks for the report @stefanowp2021 and welcome to WordPress Trac. I'm unable to reproduce this problem on a fresh installation of WordPress Multisite. The
is_network_admin()function is working as expected in the network admin area.Can you confirm whether the problem persists if you deactivate your plugins and switch to a default theme such as Twenty Twenty One? Don't forget to check for any plugins in
wp-content/mu-pluginsor awp-content/sunrise.phpfile too.