Page 1 of 1

Limiting access to a form/php

PostPosted: July 30th, 2011, 12:24 pm
by dapike
What I would like to do is to have a form on a webpage that everybody can see, but I want the php script from the line

<form action="do_something_spiffy.php" method="get">

to only function for logged in members. I've tried putting the php script within the s2member-files/access-s2member-level1 directory, but this resulted in a nasty error message even for logged-in members.

Also, the php script evidently is beyond the scope of being able to use functions such as
if (is_user_logged_in()) { // do spiffy stuff }
so I can't embed code into the php script to check the user's status.

Does anybody have any suggestions for how to achieve what I'd like to accomplish?

Thanks,

- David.

Re: Limiting access to a form/php

PostPosted: July 30th, 2011, 11:03 pm
by Cristián Lávaque
You could have your form protected inside a conditional so only those that can use the form can actually see it. WP Admin -> s2Member -> API / Scripting -> Simple/Shortcode Conditionals and Advanced/PHP Conditionals

And the do_something_spiffy script can be inside a WordPress page with Exec PHP installed, then you'll have the WP and s2Member functions available. https://wordpress.org/extend/plugins/exec-php/