How to make wordpress blog completely invisible to public [Not Private] -
i want close wordpress blog have public , keep myself.
i know can set private shows uggly log-in page , dont want people trying access (using random usernames/pass etc) or think still open members accounts or that.
i blog point " server not found " public , when logged in admin able see posts , backend aswell frontend.
how can make possible?
my suggestion following:
function is_login_page() { return in_array( $globals['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ); } function wpse_make_blog_private() { if ( ! is_user_logged_in() && ! is_admin() && ! is_login_page() ) { global $wp_query; $wp_query->set_404(); } } add_action( 'wp', 'wpse_make_blog_private' );
it show 404 on pages still allow login. logged in users see site normal.
on request show broken site add following code functions.php. aware instead of code above.
function is_login_page() { return in_array( $globals['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ); } function wpse_make_blog_private() { if ( ! is_user_logged_in() && ! is_admin() && ! is_login_page() ) { die(); } } add_action( 'wp', 'wpse_make_blog_private' );
you have option of using wp_die instead add error message minimal styling. see: https://codex.wordpress.org/function_reference/wp_die
Comments
Post a Comment