can_edit_network() WordPress Function

The can_edit_network() function is used to check if the current user can edit the network settings. This function is only available for multisite installations.

can_edit_network( int $network_id ) #

Whether or not we can edit this network from this page.


Description

By default editing of network is restricted to the Network Admin for that $network_id. This function allows for this to be overridden.


Top ↑

Parameters

$network_id

(int)(Required)The network ID to check.


Top ↑

Return

(bool) True if network can be edited, otherwise false.


Top ↑

Source

File: wp-admin/includes/ms.php

function can_edit_network( $network_id ) {
	if ( get_current_network_id() === (int) $network_id ) {
		$result = true;
	} else {
		$result = false;
	}

	/**
	 * Filters whether this network can be edited from this page.
	 *
	 * @since 3.1.0
	 *
	 * @param bool $result     Whether the network can be edited from this page.
	 * @param int  $network_id The network ID to check.
	 */
	return apply_filters( 'can_edit_network', $result, $network_id );
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.