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™

Hooks vs. Notifications

s2Member Plugin. A Membership plugin for WordPress®.

Hooks vs. Notifications

Postby martonic » July 20th, 2010, 11:48 am

Hi Jason,

s2Member API / Notifications looks useful, but I'm concerned about security - couldn't someone make their own http call and cause bad things to happen?

So, can the same functionality be achieved through hooks?

I see hooks like:

Code: Select all
do_action ("ws_plugin__s2member_during_paypal_notify_during_subscr_signup_wo_update_vars", get_defined_vars ());


Can I use it for this purpose? Thanks!
User avatar
martonic
Experienced User
Experienced User
 
Posts: 70
Joined: July 14, 2010

Re: Hooks vs. Notifications

Postby Jason Caldwell » July 22nd, 2010, 7:59 am

Absolutely. Either/or is fine.
If you can use Hooks/Filters ( I recommend them ).
Otherwise, if you don't know PHP, you can use the s2Member API Notifications.
~ You sound like a developer, so yes... ( use Hooks/Filters )

API Notifications are secure too:
When you configure an API Notification, the URLs being processed are only editable by you, from within your Dashboard, under s2Member -> API Notifications. If you're concerned about security with the receiving URL, you could always configure the API Notification with a secret key in the URL.
Code: Select all
http://mysite.com/do-something-special.php?secretKey=628983412-02342230412984532342
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Hooks vs. Notifications

Postby martonic » July 22nd, 2010, 1:58 pm

Hi Jason,

Thank you very much.

One issue with using hooks is analyzing the array structure returned by get_defined_vars for each hook we need (registration, payments, refunds etc.). Another issue, then, is not knowing if that array structure will remain stable across possible s2member upgrades. So, maybe notifications are the way to go, after all.

I did not see examples of the notification URLs.

Can I assume that the syntax works like this:

Code: Select all
    http://mysite.com/do-something-special.php?name=%%full_name%%&item=%%item_number%%


Also, would a relative address work as well, for example:

Code: Select all
    /special_directory/do-something-special.php?name=%%full_name%%&item=%%item_number%%


Thanks again.
User avatar
martonic
Experienced User
Experienced User
 
Posts: 70
Joined: July 14, 2010

Re: Hooks vs. Notifications

Postby Jason Caldwell » July 22nd, 2010, 3:19 pm

Yes, this is correct:
Code: Select all
http://mysite.com/do-something-special.php?name=%%full_name%%&item=%%item_number%%

Also, would a relative address work as well, for example:

No. Don't use relative URLs. s2Member has to assume that your Notification URLs live externally, and since they are processed with the WP_Http class, they must begin with http:// or https://

One issue with using hooks is analyzing the array structure returned by get_defined_vars for each hook we need (registration, payments, refunds etc.). Another issue, then, is not knowing if that array structure will remain stable across possible s2member upgrades. So, maybe notifications are the way to go, after all.

I think that's a very good observation; and, I agree. There are ups and downs to both methods. API Notifications are less likely to change from one version to the next; because they are built into s2Member as a major feature. Whereas Hooks/Filters are directly in the code, always subject to change.

We make every effort to preserve Hooks/Filters from one version to the next. Normally, we add new Hooks/Filters; very seldom will you see a Hook/Filter removed. That being said, ( you are right ) it's always possible that a change will be required in a future release. If we have to remove a Hook/Filter in order to improve s2Member in a future release, we WILL do that without hesitation.

Alternatively, using a Hook/Filter gives you access to the routine itself. Not only will you have access to more information within a Hook/Filter, you will also be processing your custom code within the execution of the event itself. This has advantages as well. For instance, if you need to do something within your custom routine that requires access to another s2Member function, or to another WordPress function, reference, database class, etc... this is all easier to deal with inside a Hook/Filter.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 6 guests

cron