Thank you for your inquiry.
The hack I posted is meant as more of a guideline to how you could do this. To accomplish what you need you’ll need to check each section, by using PHP’s explode()
function.
Perhaps something like this:
<?php
function s2hack_auto_login_ip()
{
$ip_min = 123.45.0.0;
$ip_max = 123.45.206.235;
$ip_cur = $_SERVER['REMOTE_ADDR'];
$ip_min_exp = explode('.', $ip_min);
$ip_max_exp = explode('.', $ip_max);
$ip_cur_exp = explode('.', $ip_cur);
if($ip_cur_exp[0] >= $ip_min_exp[0] && $ip_cur_exp[0] <= $ip_max_exp[0])
{
if($ip_cur_exp[1] >= $ip_min_exp[1] && $ip_cur_exp[1] <= $ip_max_exp[1])
{
if($ip_cur_exp[2] >= $ip_min_exp[2] && $ip_cur_exp[2] <= $ip_max_exp[2])
{
if($ip_cur_exp[3] >= $ip_min_exp[3] && $ip_cur_exp[3] <= $ip_max_exp[3])
{
/**/
$id = 1; # The ID of the user you wish to log the visitor in as / Could also be User's Login
/**/
$user = new WP_User($id);
$user_pass = md5($user->user_pass);
/**/
wp_login($user_login, $user_pass, true);
wp_setcookie($user_login, $user_pass, true);
wp_set_current_user($user->ID, $user_login);
}
}
}
}
}
add_action('plugins_loaded', 's2hack_auto_login_ip');
The above code isn’t tested, and may need some tweaks.
That’s about as far as we can go with custom code. If you need further assistance, we recommend
http://jobs.wordpress.net, or another freelance web site where WordPress® experts are offering their expertise through a bid on your project.