[wp-trac] [WordPress Trac] #56296: is_network_admin() function does not work correctly on multisite

WordPress Trac noreply at wordpress.org
Thu Jul 28 10:02:33 UTC 2022


#56296: is_network_admin() function does not work correctly on multisite
----------------------------+-----------------------------
 Reporter:  stefanowp2021   |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 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".

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56296>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list