How to block even direct link to img on running a Private site with Network
-
Hi!
I am developing a private blog hosting service with the network function, and the big problem was the fact everybody can see the images when they type the direct link on browsers.
(outsiders won’t know the link but safer’s better)You want it invisible for non-logged-in users, while logged-ins can enjoy everything.
The solution goes:
- get your wp-includes/ms-files.php.
- paste the code below on line20, after error_reporting( 0 );
- save it.
the code says:
require( ABSPATH . WPINC . '/capabilities.php' ); require( ABSPATH . WPINC . '/user.php' ); require( ABSPATH . WPINC . '/formatting.php' ); require( ABSPATH . WPINC . '/meta.php' ); wp_plugin_directory_constants( ); ms_cookie_constants( ); wp_cookie_constants( ); require( ABSPATH . WPINC . '/pluggable.php' ); if ( !is_user_logged_in() ) { status_header(404); die('go home baby!!'); }
The ms-files.php file does something about images.
You can’t use is_user_logged_in tag by default and the codes before “if” enable it.It’s all thanks to a Japanese engineer jim0912!
- The topic ‘How to block even direct link to img on running a Private site with Network’ is closed to new replies.