PriMoThemes — now s2Member® (official notice)
This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™
<?php
function auto_login_for_specific_ip ()
{
//Change this to the correct page id for your Membership Options Page
$page_id = 10;
//Customize this to the static IP you mentioned earlier
$user_ip = '127.0.0.1';
//Customize this to the correct user login for the users
$user_login = 'demo';
//Customize this to the correct password.
$user_pass = 'demo';
//If the user is logged in, or if the IP doesn't match, exit the script
if (is_user_logged_in () || $_SERVER['REMOTE_ADDR'] != $user_ip)
exit ();
//To prevent errors
wp_reset_query();
//Check to see if page is correct.
if (is_page ($page_id))
{
//Should be set if the user is trying to access a protected page.
$redirect = $_GET['s2member_seeking'];
//To find the correct page/post id's
$redirect = str_replace (array('page-', 'post-'), array('?page_id=', '?p='), $redirect);
//Send Login Details
echo '<form id="autologin" action="' . get_option ('siteurl') . '/wp-login.php?redirect_to=/' . $redirect . '" method="post"><input type="hidden" name="log" value="' . $user_login . '"/><input type="hidden" name="pwd" value="' . $user_pass . '"/></form>';
echo '<script type="text/javascript"> function javaautolog () { var frm = document.getElementById("autologin"); frm.submit(); } window.onload = myfunc;</script>';
}
}
add_action ('wp_head', 'auto_login_for_specific_ip');
?>
<?php
function auto_login_for_specific_ip ()
{
//Change this to the correct page id for your Membership Options Page
$page_id = 10;
//Customize this to the static IP you mentioned earlier
$user_ip = '127.0.0.1';
//Customize this to the correct user login for the users
$user_login = 'demo';
//Customize this to the correct password.
$user_pass = 'demo';
//If the user is logged in, or if the IP doesn't match, exit the script
if (is_user_logged_in () || $_SERVER['REMOTE_ADDR'] != $user_ip)
exit ();
//To prevent errors
wp_reset_query();
//Check to see if page is correct.
if (is_page ($page_id))
{
//Should be set if the user is trying to access a protected page.
$redirect = $_GET['s2member_seeking'];
//To find the correct page/post id's
$redirect = str_replace (array('page-', 'post-'), array('?page_id=', '?p='), $redirect);
//Send Login Details
echo '<form name="autologin" action="' . get_option ('siteurl') . '/wp-login.php?redirect_to=/' . $redirect . '" method="post"><input type="hidden" name="log" value="' . $user_login . '"/><input type="hidden" name="pwd" value="' . $user_pass . '"/></form>';
echo '<script type="text/javascript">document.autologin.submit();</script>';
}
}
add_action ('wp_head', 'auto_login_for_specific_ip');
?>
Users browsing this forum: Exabot [Bot] and 1 guest