Get Involved
Home
Discover
Hire
Natively, Voxel cannot do a site wide visibility to make it so the entire site is behind a login wall, this snippet does that. Change the URL as needed.
function redirect_non_logged_in_users() {if (!is_user_logged_in() && !is_page('login-registration')) {$current_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";$encoded_url = urlencode($current_url);error_log('Redirecting non-logged in user from: ' . $current_url); // Optional: for debuggingwp_safe_redirect('https://staging.voxel.guide/login-registration?redirect_to=' . $encoded_url); //BE SURE TO CHANGE THIS URLexit;}}add_action('template_redirect', 'redirect_non_logged_in_users'); function custom_login_redirect($redirect_to, $request, $user) {if (isset($user->roles) && is_array($user->roles) && !empty($_REQUEST['redirect_to'])) {return esc_url($_REQUEST['redirect_to']);} else {return admin_url();}}add_filter('login_redirect', 'custom_login_redirect', 10, 3);
function redirect_non_logged_in_users() {if (!is_user_logged_in() && !is_page('login-registration')) {$current_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";$encoded_url = urlencode($current_url);error_log('Redirecting non-logged in user from: ' . $current_url); // Optional: for debuggingwp_safe_redirect('https://staging.voxel.guide/login-registration?redirect_to=' . $encoded_url); //BE SURE TO CHANGE THIS URLexit;}}add_action('template_redirect', 'redirect_non_logged_in_users');
function custom_login_redirect($redirect_to, $request, $user) {if (isset($user->roles) && is_array($user->roles) && !empty($_REQUEST['redirect_to'])) {return esc_url($_REQUEST['redirect_to']);} else {return admin_url();}}add_filter('login_redirect', 'custom_login_redirect', 10, 3);
Are you sure you want to exit? Your current conversation will be lost.