Page 1 of 1

API Scripting Question

PostPosted: October 24th, 2010, 11:49 pm
by KirkWard
Is it possible to use a "mail" command in the s2Member API / Notifications for the Registration and/or Payment Notifications?

I want to do something like ...
Code: Select all
<?php
mail( "%%role%%@somewhere.com", "subject", "message", "From: %%user_email%%" )
?>

... as a way to do an email subscription to a list based on the s2 member level. Or, possibly, the item number.

Or, do I have to send the variables to a script containing that code?

Re: API Scripting Question

PostPosted: October 25th, 2010, 7:02 am
by webboy
Would be better to writing a script to select the members you want to email from the wordpress database or use a 3 party emailing system like A webber

Re: API Scripting Question

PostPosted: October 26th, 2010, 2:51 am
by Jason Caldwell
I agree with "webboy". I would use one of the services that are pre-integrated with s2Member. Such as AWeber or MailChimp. See: s2Member -> API List Servers in your Dashboard.

However, here is a sample PHP routine that may give you some ideas.
Code: Select all
foreach (get_users_of_blog () as $user)
    {
        $user = new WP_User ($user->ID);
        #print_r($user); /* to get a full list of $user-> variables when debugging. */
        mail ($user->user_email, "Subject", "Body", "From: you@yoursite.com\r\nContent-Type: text/plain; charset=utf-8");
    } 

Re: API Scripting Question

PostPosted: October 26th, 2010, 11:16 am
by KirkWard
Thanks,

I use a self hosted autoresponder called "AutoResponsePlus." It has worked well for many years and I have a bit more control over user registration than if I used a service. I want to simultaneously sign up my members as subscribers when they register, and terminate them when they reach EOT.

I can subscribe and unsubscribe them by email, using the ARP remote serive. I merely have to format the email correctly, including a username and password. ARP uses the "to" part of the address as the name of the autoresponder campaign, and the "from" part of the address as the name to add to the list.

In my other system (using a different membership script), I name my campaigns to match the item name as sent to PayPal. I would like to do the same here, which means I need to pass the item name and the users email address to the script.

That is why I structured the email including those two items. I can write the mail() function into a short script, if I can get the itemname and useremail variables there as parameters in the url. To wit ...

Code: Select all
http://mydomain.com?email=%%email%%&item=%%itemname%%


So, do I need to include the question mark and the ampersands when formatting the URL in the api scripting?

Re: API Scripting Question

PostPosted: October 27th, 2010, 11:21 pm
by Jason Caldwell
H Kirk. I'm not sure I understand completely, but I think you're referring to API Notifications. So the URL you posted above, might be pasted into the API Notification field for Payment Notifications ( or possibly another event ), as found in your Dashboard under: s2Member -> API Notifications.

However, your URL should look something like this:
Code: Select all
http://www.example.com/some-script.php?email=%%payer_email%%&item=%%item_name%%&item_number=%%item_number%%
You will find a more complete documentation on these Replacement Codes in your Dashboard, under: s2Member -> API Notifications.

----------------- some-script.php --------------------
As referenced in the URL above, would be a script that you write, which responds in some way to the Notification event processed by s2Member.

Re: API Scripting Question

PostPosted: October 28th, 2010, 10:46 am
by KirkWard
Thanks Jason,

I think that is exactly what I was looking for!

Kirk

Re: API Scripting Question

PostPosted: October 29th, 2010, 2:43 am
by Jason Caldwell
You are VERY welcome Kirk.
Glad I could help.