Using the API or a hook to manage a user in 3rd party software

Let me rephrase my question, i have some software similar to a coupon book that i want to offer to paid members. level 1 or higher. i need to have a few things happen as i have to pay per member account in the coupon book software, so i want to make sure the users are handled according to payments made in s2Member.

  1. create a user in the other software when the s2member is promoted or joins @ level 1.
  2. deactivate a user if they drop from level 1 to 0
  3. deactivate a user if they cancel level 1 membership.
    the 3rd party software has an api. it also takes care of communication with the user regarding their account/password. all i will need to send with the API is the email address and a user ID, we will probably use a phone number for the ID not the wordpress user ID.

my question is what would be the best way to do this in s2Member? i had it working back in 2017 but the company went another route and deleted the site, so other than the testing files i can not remember how i implemented it in s2Member.

Sean

Hi Sean.

It sounds like you could pass those details to the other software’s API, using s2Members Notifications, and a script that ties them together. WP Admin > s2Member > API / Notifications

See also: https://s2member.com/kb-article/building-an-api-notification-handler-webhook/

I hope that helps. :slight_smile:

thanks, that’s the route i am going. for some reason i thought there was an easier method.

1 Like

running into a bit of a hurdle,
i am using the default example from https://s2member.com/kb-article/building-an-api-notification-handler-webhook/ under “Another Variation with More Elaborate Examples”

in the section marked // I can also pull s2Member option values related to this user.
its not grabbing any data. with this code
$s2member_subscr_id = get_user_option(‘s2member_subscr_id’, $user_id);
$s2member_phone = get_user_option(‘phone_number’, $user_id);
$s2member_city = get_user_option(‘city’, $user_id);
$s2member_state = get_user_option(‘state’, $user_id);

i am getting info from wordpress with.
$first_name = $user->first_name;
$last_name = $user->last_name;
$email = $user->user_email;
$username = $user->user_login;

so this tells me i can assume i am using the correct $user_id there.
any direction to look at getting the s2member info from the registration form?

if it matters… i am using Registration Notifications to trigger the hook.

Sean

i fixed some of this when i saw my user field mistake by changing to get_user_field from get_user_option.

$s2member_phone = get_user_field(‘phone_number’, $user_id);
$s2member_city = get_user_field(‘city’, $user_id);
$s2member_state = get_user_field(‘state’, $user_id);

not sure why this is not pulling the ID
$s2member_subscr_id = get_user_option(‘s2member_subscr_id’, $user_id);
Sean

got the $user_id sorted out.

i need to run 1 more function… if the user gets downgraded from level 1 to level 0.

some people may come in at level 0 as free members. and may later upgrade to level 1 at a later date. this is function is handled by a payment notification. what should happen is if a payment is not made for what ever reason, they get downgraded to level 0, it would process the function which removes them from the “coupon book software” but keeps them as a member with limited benefits.

where i am stuck is checking the level change. i am assuming the Modification Notifications api is where this would go, what i haven’t been able to find is how to test if this person was level 1 and now level 0. or am i over thinking this? as of today, we should only have 2 levels… but this could change tomorrow.
thanks

Sean