humanmade / network-media-library

Network Media Library plugin for WordPress Multisite
MIT License
290 stars 55 forks source link

Changing default site ID #53

Closed Lycurgue closed 5 years ago

Lycurgue commented 5 years ago

Hi,

I'd like to change the default site ID from 2 to 1. From the installation instructions I have to use the following filter:

add_filter( 'network-media-library/site_id', function( $site_id ) {
    return 123;
} );

Can you tell me where I have to put this code in network-media-library.php?

I also saw in network-media-library.php in line 56

 const SITE_ID = 2;

Do I need to change _const SITEID = 2;

Thanks,

François Maurice

tmort commented 5 years ago

I just installed the plugin and placed the filter inside my functions.php, changing the ID to "1" for my main site. Try adding it to your themes functions.php and see if that does the trick.

Lycurgue commented 5 years ago

Hi @tmort

Finally, I simply modify const _SITEID = 2 to const _SITEID = 1 and it does the trick !

But, I'm curious. Where you put the filter in the functions.php file ?

Thanks,

François

johnbillion commented 5 years ago

@Lycurgue If you're not familiar with actions and filters in WordPress then I'd suggest reading a few articles about them to familiarise yourself. They're one of the most important features of WordPress.

You can place this code anywhere in the functions.php file of your theme, or you can create a mu-plugin and placed the code in there. There are lots of resources online about these processes.

Good luck!

Lycurgue commented 5 years ago

Thanks @johnbillion,

I'll do my homework ;-)

François

regivanx commented 5 years ago

Hello, forgive me for insisting, but I do not know PHP programming. I use Bash, wp-cli or Composer, but I do not know how to program a filter hook.

Would it not be possible to say: "write this in a file with such name, and put it in such folder"?

I converted my wordpress site into a network, added a second site, and then installed Network Media Library with Composer. Adding images to the site library id = 1 or id = 2 does not echo in the other library.

Both sites have different themes.

I tried to create a mu-plugin by writing a site_id.php file:

<?php add_filter( 'network-media-library/site_id', function( $site_id ) { return 1; } ); ?>

and I put it in wp-content/mu-plugins.

It does not work.

I do not know what to do now, I do not know PHP, I do not know where to look.