New answers tagged

0

This in your header.php or before the get_header() call in any template will redirect a user who isn't logged in and who tries to reach any page of your site to the login page: if( !is_user_logged_in() ) { wp_redirect( wp_login_url() ); exit; } This will redirect all users to the home page after login: function tbdn_login_redirect( $redirect_url ...


1

If I understood correctly, you need to check if the user is logged in, if not, redirect it to login page. If the user logs in succesfully, he should be redirected to the page he was trying to see. You can do this by using the redirect argument of wp_login_url(). This code should work (not tested): add_action( 'init', 'cyb_restrict_guest_access' ); ...


0

You can use following code to check home page or not: if(is_home() && !is_user_logged_in()){ wp_redirect( wp_login_url() ); exit; }


2

get_option is a per sub-site function. In other words it gives you only the value of the option in the sub-site. If you want to have a netwrok wide option you should use get_site_option and update_site_option. You can also query an option from a specific sub-site by using get_blog_option and passing as parameter to it the main sub-site id, but in my ...



Top 50 recent answers are included