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.

Restricting access to a php page

Home Forums Community Forum Restricting access to a php page

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

Topic Author Topic
Posted: Tuesday May 8th, 2012 at 11:56 am #12912
hbgi
Username: hbgi

Hello,

I really tried to solve this myself with the videos, articles, and forum search, but I must be missing some kind piece of info or doing something wrong.

We had someone create a calculator for us using php. It works great and to access it, you would go to http://mydomain/Calculator/calculator.php

But this is something that should only be accessible by paid members, so I want to restrict it to level 1 members. I just can’t seem to get it to work behind the “membership wall.”

I tried using the URI restrictions, but it is still accessible without logging in.

So I found the article on Non-WordPress Content with S2Member:
http://www.s2member.com/kb/protecting-non-wordpress-content-with-s2member/

That sounded like exactly what I needed to do, but I’m not an experience developer or anything and I don’t understand where this code is supposed to go.

I tried adding it to the php file but ended up with errors when I clicked http://mydomain/Calculator/calculator.php

I tried different variations and nothing seems to work. What am I doing wrong? I need some advice.

Thanks so much.

joanne

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Wednesday May 9th, 2012 at 2:16 am #13036
Raam Dev
Username: Raam
Staff Member

Hi Joanne,

Could you show us the code that you added to calculator.php? Also, if you could give us the site URL, that would help with diagnosing the problem.

Posted: Wednesday May 9th, 2012 at 9:48 am #13051
hbgi
Username: hbgi

Hi Raam,

Here is the code I added:

It is added at the beginning and the rest of the code follows:
<?php
/*
* "Calculator.php"
*
* History:
* ——— and so on and so on…..

I tried other variations of the include_once line in case the path was incorrect.
The domain is diypracticesales.com
The WordPress files and the Calculator_v2 file are set up in public_html/diypracticesales.com/ (no separate WordPress directory)

To URL to the calculator is:
http://diypracticesales.com/Calculator_v2/Calculator.php

At this point when you click that URL I am getting this error:

Warning: include_once(wp-load.php) [function.include-once]: failed to open stream: No such file or directory in /home/hbgi/public_html/diypracticesales.com/Calculator_v2/Calculator.php on line 2

Warning: include_once() [function.include]: Failed opening 'wp-load.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/hbgi/public_html/diypracticesales.com/Calculator_v2/Calculator.php on line 2

Fatal error: Call to undefined function current_user_can() in /home/hbgi/public_html/diypracticesales.com/Calculator_v2/Calculator.php on line 3

In trying to use the URI restrictions I put :
/Calculator_v2
/Calculator_v2/Calculator.php

Let me know if you need any other info. Thanks so much for your help!

Joanne

Posted: Friday May 11th, 2012 at 10:49 am #13204
hbgi
Username: hbgi

Hey there,

Just checking in. Were you able to look into this issue?

Thanks,

Joanne

Posted: Friday May 11th, 2012 at 10:05 pm #13247

Hi Joanne. Your location of wp-load.php is probably not properly written in the include. I can’t tell because I haven’t seen your code, but the error says it couldn’t include it, and the location may be the reason.

[hilite code]include_once "wp-load.php";[/hilite] works fine if your script is in the same dir, but if not, you’ll have to modify that to point to it. If you put a slash at the beginning, it’ll start in the site’s root dir. So, if you have WP in that dir, try [hilite code]include_once "/wp-load.php";[/hilite].

If this keeps giving you trouble, I suggest that you contact the person that coded the calculator script to help you integrate it with WordPress.

I hope that helps. :)

Viewing 4 replies - 1 through 4 (of 4 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.