Page 1 of 1

Post/Page restriction not working (local issue?)

PostPosted: July 14th, 2010, 6:17 pm
by scripty
I'm running into a problem where all pages and posts are being displayed when they shouldn't be. I have pages and posts restriction both set to "all" - I did confirm that a "membership" page is set and defined in the settings. I tried to access the site with another browser (to make sure it didn't see me as logged in) - and all pages and posts are displayed (not restricted). I was testing this out on a local copy of WordPress using the new default theme (twenty ten) - no other plugins are running.

Does this plugin have any known issues running on a locally hosted copy of WordPress (I'm running MAMP)

Thanks in advance for any help!
-Jennifer

Re: Post/Page restriction not working (local issue?)

PostPosted: July 14th, 2010, 9:02 pm
by Jason Caldwell
Hi Jennifer. Thanks for reporting this bug.

Yes, there is one minor change required.
Inside /includes/functions/is-systematic.inc.php, at line #37

Change this:
Code: Select all
else if ($_SERVER["REMOTE_ADDR"] === $_SERVER["SERVER_ADDR"])

To this:
Code: Select all
else if ($_SERVER["REMOTE_ADDR"] === $_SERVER["SERVER_ADDR"] && $_SERVER["REMOTE_ADDR"] !== "127.0.0.1")

If that does not work, you can change 127.0.0.1 to whatever your localhost IP is. I'll have this updated in the next release so that local installations will work without this manual edit.

Re: Post/Page restriction not working (local issue?)

PostPosted: July 14th, 2010, 9:42 pm
by scripty
PHEW! I thought I was going crazy. That did work - but strangely instead of an IP I had to put this in instead:
::1
I'm not a MAMP expert, so I don't know why that is - but that's the value it returns for $_SERVER["REMOTE_ADDR"]

Thanks!
-Jennifer

Re: Post/Page restriction not working (local issue?)

PostPosted: July 14th, 2010, 10:13 pm
by Jason Caldwell
OK, cool. Thanks for your response Jennifer.

So maybe a better solution is this:
Code: Select all
else if ($_SERVER["REMOTE_ADDR"] === $_SERVER["SERVER_ADDR"] && !preg_match ("/^localhost$/i", $_SERVER["HTTP_HOST"]))

If you have a minute to test this on your MAMP installation, I would be very grateful.

Re: Post/Page restriction not working (local issue?)

PostPosted: July 14th, 2010, 10:33 pm
by scripty
That doesn't seem to do the trick. With that line in place, it's showing me all the pages it's not supposed to be.

Not sure if this is helpful or not, but with MAMP - it goes through a port... so the URL looks like this:
http://localhost:8888/

Re: Post/Page restriction not working (local issue?)

PostPosted: July 14th, 2010, 10:49 pm
by Jason Caldwell
OK. Thank you very much. Here is another attempt that takes the port number into account as well.
Code: Select all
else if ($_SERVER["REMOTE_ADDR"] === $_SERVER["SERVER_ADDR"] && !preg_match ("/^localhost(\:[0-9]+)?$/i", $_SERVER["HTTP_HOST"]))

Re: Post/Page restriction not working (local issue?)

PostPosted: July 14th, 2010, 10:54 pm
by scripty
That works! Thanks!

Re: Post/Page restriction not working (local issue?)

PostPosted: July 14th, 2010, 11:01 pm
by Jason Caldwell
Beautiful. Thanks for the help!
- This will be committed to s2Member v3.1.3+ ... to be released soon.

Re: Post/Page restriction not working (local issue?)

PostPosted: July 14th, 2010, 11:08 pm
by Jason Caldwell
Jennifer. I just sent you a login for s2Member.com; which includes a free copy of s2Member Pro, with unlimited domain licensing and the s2Clean Theme. ~Thanks again for the assistance. Much appreciated!

Just send me a list of domains and/or IP addresses via email and I'll send over your licenses on demand.

Re: Post/Page restriction not working (local issue?)

PostPosted: July 14th, 2010, 11:14 pm
by scripty
You totally rock!! Thanks so much! :D

Re: Post/Page restriction not working (local issue?)

PostPosted: July 22nd, 2010, 11:43 pm
by Jason Caldwell
"localhost" support added in s2Member v3.1.4+.
~ Thanks again.