Global Media Library Hook Reference

Documentation of action and filter hooks, which can be used for precise customization of the Multisite Shared Media Library plugin for WordPress.

rudr_sml_network_library_allowed

Allows you to completely prevent access to the global media library from specific sub-sites of the multisite network.

$is_allowed = apply_filters( 'rudr_sml_network_library_allowed', $is_allowed, $blog_id );
$is_allowedbool
Whether the access to the network media library is allowed or not.
$blog_idint
A sub-site ID.

Example – let’s say that we never want to allow users of the sub-site with ID=5 to have access to the global media files, then we need to use the following snippet:

add_filter( 'rudr_sml_network_library_allowed', function( $is_allowed, $blog_id ) {
	
	if( in_array( $blog_id, array( 5 ) ) ) { // provide as many blog IDs as you want
		$is_allowed = false;
	}
	
	return $is_allowed;
}, 25, 2 );

rudr_sml_network_library_id

Allows you to override the “Network Library” option from Settings > Network Media. Before plugin version 1.9, it was also the only way to change the network library site ID.

$network_library_id = apply_filters( 'rudr_sml_network_library_id', $network_library_id );
$network_library_idint
The site (blog) ID you would like to use as the network media library.

Example:

/**
 * Plugin name: Change Network Media Library Site
 * Author: Misha Rudrastyh
 * Version: 1.0
 * This plugin allows to change the ID of the network media library main site.
 * Network: true
 */
add_filter( 'rudr_sml_network_library_id', function( $network_library_id ) {
	// set a site with ID = 2 as a multisite global media library
	$network_library_id = 2;
	
	return $network_library_id;
} );

Don’t know how to use this code snippet?

Just create any PHP file in your wp-content/plugins folder, for example change-network-library-site.php, and paste this code there. Then go to “Plugins,” and network activate this brand new plugin. Another way is to use this code as a code snippet.

rudr_sml_shared_media_tab_title

Allows you to change the title of the “Shared media” tab.

$tab_title = apply_filters( 'rudr_sml_shared_media_tab_title', __( 'Shared media', 'rudr-multisite-shared-media' ) );
$tab_titlestring
By default – “Shared media”.

Example:

add_filter( 'rudr_sml_shared_media_tab_title', function( $tab_title ) {
	$tab_title = 'Global media';
	return $tab_title;
} );

Result:

Custom shared media tab title

Need more help?