I trying to use this snippet to prevent anyone who doesn’t has a specific word in his username to describe the device he use to login into the website from using the website
this code is not doing anything at all , I’m using a plugin called “code snippets”
<?php
if( is_front_page() ) {
$userag = $_SERVER['HTTP_USER_AGENT'];
$current_user = wp_get_current_user();
$usern = $current_user->user_login;
$appleAgent = str_contains($userag, "Mac");
$appleIos = str_contains($usern, "ios");
$appleMac = str_contains($usern, "mac");
if( ($appleAgent == 1 && $appleMac == 1) || ($appleAgent == 1 && $appleIos == 1) ){
echo "";
}elseif( ($appleAgent == FALSE && $appleIos == FALSE && $appleMac == FALSE) ){
echo "";
}else{ echo "<script>location.href='https://www.google.com/';</script>"; }
}
?>
is there any way to make this work?