Your Members Third Party integration
Warning work in progress
Your Members allows third party integration with almost anything and hopefully this guide will help you get your third party apps working with Your Members.
Please note: We can’t write guides for every single application on the planet this guide is therefore generic and we have tried to make it easy to follow and hopefully it should be easy to adapt for your application.
Server or Client Integration
Your Members offers two main ways to interact with Your Members either through server side hooks or via client side scripts which are run on return from a location such as Paypal.
Your Members Client Integration – Javascript
Since Your Members first released we have included a simple method for running Javascript on return from Paypal this is very much a legacy system but should you wish to add javascript calls then in Payment Gateways → Paypal (Standard)
The place the javascript you want within the Additional Callback script.
Please note you must use the dedicated return URL wp-login.php?from_paypal=true
This is useful if you just need to add a quick bit of code such as affiliate code so if it looked like:
< script id="pap_xxxxxxxx" src="http://www.example.com/affiliate/scripts/sale.js" type="text/javascript">< /script>
This callback will be replaced with Thankyou integration in Your Members 1.4.5
Server Side integration
This is the most flexible method of integration with Your Members but does require some programming, we recommend people write dedicated plugins for these additions (see code below for basics)
Anatomy of a Server Side integration
Request function
Nearly all third party integration involves sending data to another server or application the most common way to do this is through CURL or Fopen to make a post request, Wordpress 2.7 has an expanded system for doing this but unless you are brave and have upgraded you may find it easier to do it yourself, either by copying code provided to you by the third party or using our example code below.
Server Side Hooks
Your Members can trigger off code written by third party at certain points in the registration and upgrade process. The hooks work like standard Wordpress actions so if you have used them before then you will find this system really flexible.

Current Hooks are:
Current Hooks in 1.4.2
- Free Registration/Downgrade – ym_return_free
- Trial Upgrade/Downgrade – ym_return_trial
- Paypal (Standard) Membership upgrade/downgrade – ym_return_paypal
- Paypal (Standard) Client call – ym_return_free_js
New Hooks in 1.4.5
- Paypal (Standard) PPP Purchase (1.4.5) – ym_return_paypal_ppp
- Clickbank Membership upgrade/downgrade (1.4.5)- ym_return_clickbank
- Clickbank PPP Purchase (1.4.5) – ym_return_clickbank_ppp
- Worldpay/Thankyou (1.4.5) – ym_return_thankyou
Pulling user Data
In 1.4.2 we have 3 payment modules and the default hooks all occur after payment and account generation has occurred however we do run into a small snag as the different payment types were written at different points in Your Members evolution and so each handle this last stage differently and produce a unique request string to expand to grab user data.
Free Payment Module
list($user_id, $account_type) = explode('_', $_REQUEST['custom']);
Free Account only returns user_id and $account_type which we already know because the return_free hook is only called after the account type has been set.
Trial Payment Module
list($cost, $user_id, $duration, $duration_type) = explode('_', $_POST['custom']);
Trial returns user and also the cost/duration (remembering you can have multiple trial subscriptions at different costs) what it doesn't return is an account type not a problem since we would only call this through the trial hook if you are running code which will want to know the account type you can set it simply by:
$account_type = __('Trial','ym');
Paypal Payment Module
list($duration, $amount, $currency, $user_id, $account_type, $duration_type) = explode('_', $_POST['custom']);
Paypal has a lot more data and its important to remember unlike Free and Trial we need to extract the account type as it maybe one of multiples depending on how many account types you have set up.
Writing your Plugin
Combining it altogether ok so lets create an example plugin for this example we will use Autoresponder Plus 3, create a new php file called ym-autoresponder.php in your plugins folder.
Plugin Info
All plugins need some basic info held as a PHP comment at minimum you need to define a name, description and author.
/*
Plugin Name: Autoresponder code for YM
Plugin URI: http://www.newmedias.co.uk
Description: Additional Auto Responder instructions for ym
Author: Cambridge New Media Services
*/
post_data_function
This is the function that will send the data we want to send the users login and email address we also might want to allocate specific series to specific user types.
Extract users data
list($duration, $amount, $currency, $user_id, $account_type, $duration_type) = explode('_', $_POST['custom']);
$ym_custom_fields = ym_get_custom_field_array($user_id);
$ym_current_account_type = $account_type;
Is example of pulling data from the paypal string then making a call to Your Members custom fields so we can grab any additional information the user may have given us during registration.
Add hooks
Calling a hook is really simple just add add_action ('ym_return_hook_name', 'your_function_name'); in your code.
Download Example Code
Download complete example You can download the example here

Your Members Autoresponder Plugin by Cambridge New Media Services is licensed under a Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License.
I have included a small code snippet to allow you to grab a users first name to put in the autoresponder instead of their login, to do this you will need to set up a First Name, Last Name custom profile fields, select registration only. The ym_change_profile_field function will copy the custom field data into Wordpress own fields to prevent replication.
Thankyou page Integration – 1.4.5 or higher
Coming Soon - This will replace Paypals Javascript callback allowing you to create dedicated thankyou pages with the ability to combine server side includes and Javascript.


