The answer to the question depends on what you used to implement the block for unauthorized users? Is it a basic auth access protection or “only” a wordpress frontend login session? Do you use a plugin for it? If so, its developer might be the right contact for this question.
@threadi thanks for your answer. Blocking is realized this way: I got the custom code snippet in functions.php, that redirects all unauthorized users to the fully custom login page (not wp-login.php)
What code do you use for this exactly?
@threadi
add_action( 'wp', 'sc_capture_before_login_page_url' );
function sc_capture_before_login_page_url(){
session_start();
if( !is_user_logged_in() && !is_page('nobodyknowsthisurl') && !is_page('wp-admin') && !is_page('partylogin') ):
$_SESSION['referer_url'] = get_the_permalink();
endif;
}
add_action( 'template_redirect', 'redirect_to_specific_page' );
function redirect_to_specific_page() {
if ( !is_user_logged_in() && !is_page('partylogin') && !is_page('nobodyknowsthisurl') && !is_page('wp-admin')) {
wp_redirect('https://party-code.com/partylogin');
exit;
}
}
add_action('wp_logout','unlog');
function unlog(){
wp_redirect( site_url() );
exit();
}
if( !function_exists('sc_after_login_redirection') ):
function sc_after_login_redirection() {
session_start();
$redirect_url = home_url('/');
if ( isset($_SESSION['referer_url']) ):
$redirect_url = $_SESSION['referer_url'];
endif;
return $redirect_url;
exit;
}
add_filter('login_redirect', 'sc_after_login_redirection',10,3);
endif;
-
This reply was modified 3 years, 7 months ago by
andyganesh.
-
This reply was modified 3 years, 7 months ago by
andyganesh.
You could check wherever you check with is_user_logged_in() if the user is logged in also if the user has a specific user agent. The bot you have in mind would have to use this user-agent string and could then access the pages without further ado.
Example:
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if ( !is_user_logged_in() && !strpos( $user_agent, 'CostumizedAgent') && !is_page('partylogin') && !is_page('nobodyknowsthisurl') && !is_page('wp-admin') ) {
wp_redirect('https://party-code.com/partylogin');
exit;
}
I’m just not sure now what you mean by “preload bot” and where you got this assessment that it interferes with some preload process.