The network_admin_url() WordPress PHP function retrieves the URL to the admin area for the network.
Usage
network_admin_url( $path, $scheme )
Example:
Input:
network_admin_url('user-new.php', 'https');
Output:
https://www.example.com/wp-admin/network/user-new.php
Parameters
$path
(string) – Optional. Path relative to the admin URL. Default:''
.$scheme
(string) – Optional. The scheme to use. Default is'admin'
, which obeysforce_ssl_admin()
andis_ssl()
.'http'
or'https'
can be passed to force those schemes. Default:'admin'
.
More information
See WordPress Developer Resources: network_admin_url()
Examples
Basic Usage
Retrieve the network admin URL.
$url = network_admin_url(); echo $url;
Output:
http://www.example.com/wp-admin/network/
(protocol will be https when appropriate)
Custom Path
Generate URL path to the ‘Users -> Add New’ page in the admin area.
$url = network_admin_url('user-new.php'); echo $url;
Output:
http://www.example.com/wp-admin/network/user-new.php
Force HTTPS Scheme
Generate URL path to the ‘Users -> Add New’ page in the admin area and force HTTPS.
$url = network_admin_url('user-new.php', 'https'); echo $url;
Output:
https://www.example.com/wp-admin/network/user-new.php
Force HTTP Scheme
Generate URL path to the ‘Themes’ page in the admin area and force HTTP.
$url = network_admin_url('themes.php', 'http'); echo $url;
Output:
http://www.example.com/wp-admin/network/themes.php
Custom Path with Query Parameters
Generate URL path to the ‘Plugins’ page in the admin area with a search query.
$url = network_admin_url('plugins.php?s=my-plugin'); echo $url;
Output:
http://www.example.com/wp-admin/network/plugins.php?s=my-plugin