latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Automatic Login by IP range

Home Forums Community Forum Automatic Login by IP range

Tagged: ,

This topic contains 6 replies, has 3 voices. Last updated by  Cristián Lávaque 3 years, 9 months ago.

Topic Author Topic
Posted: Wednesday Apr 3rd, 2013 at 2:49 am #46449
John Potter
Username: johnp

List Of Topic Replies

Viewing 6 replies - 1 through 6 (of 6 total)
Author Replies
Author Replies
Posted: Wednesday Apr 3rd, 2013 at 5:03 pm #46526
Bruce
Username: Bruce
Staff Member

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&#91;'REMOTE_ADDR'&#93;;
		
		$ip_min_exp = explode('.', $ip_min);
		$ip_max_exp = explode('.', $ip_max);
		$ip_cur_exp = explode('.', $ip_cur);
		
		if($ip_cur_exp&#91;0&#93; >= $ip_min_exp[0] && $ip_cur_exp[0] <= $ip_max_exp&#91;0&#93;)
			{
				if($ip_cur_exp&#91;1&#93; >= $ip_min_exp[1] && $ip_cur_exp[1] <= $ip_max_exp&#91;1&#93;)
					{
						if($ip_cur_exp&#91;2&#93; >= $ip_min_exp[2] && $ip_cur_exp[2] <= $ip_max_exp&#91;2&#93;)
							{
								if($ip_cur_exp&#91;3&#93; >= $ip_min_exp[3] && $ip_cur_exp[3] <= $ip_max_exp&#91;3&#93;)
									{
										/**/
										$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.
Posted: Wednesday Apr 3rd, 2013 at 5:24 pm #46533
John Potter
Username: johnp

Thanks for your quick response Bruce.

Your suggestion confirms that this particular customization is beyond my abilities.

If you guys offered this functionality as an add-on module or even a stand-alone plugin I’m sure many users would pay extra for it.

Posted: Wednesday Apr 3rd, 2013 at 5:28 pm #46535
Bruce
Username: Bruce
Staff Member

I’ll have our development team look into adding this functionality in a future version of s2Member.

Posted: Wednesday Apr 3rd, 2013 at 5:37 pm #46538
John Potter
Username: johnp

My client might be prepared to contribute a small amount towards development costs.

If anyone else reading this needs this function, please lobby s2member to get it moved up the priority list.

I understand that both Joomla and Drupul have modules that allow auto-login by IP, but this not currently easy with WordPress.

Posted: Sunday Apr 7th, 2013 at 6:25 pm #46813
John Potter
Username: johnp

My client badly needs this functionality, so I will follow up your suggestion above of getting a free-lance developer to quote on this if you guys aren’t interested.

I’m thinking it would be so great to have a page in the s2member admin where allowed IPs, ranges of IPs and IPs with wildcards could be entered.

If they could be labeled by institution as well, to make updating simple, that would be fantastic.

And if Quick Cache could be then instructed to ignore those IPs all would be perfect.

Posted: Wednesday Apr 10th, 2013 at 4:43 am #47042

Yeah, it’ll be better/quicker if you post the job in a freelancer site. We’re really busy with development right now and can’t prioritize feature requests like this at the moment. Sorry about that, and I hope you find a very competent freelancer that does exactly what you need. :)

Viewing 6 replies - 1 through 6 (of 6 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.