latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Advice on extending S2 Member with APIs

Home Forums Community Forum Advice on extending S2 Member with APIs

This topic contains 3 replies, has 2 voices. Last updated by  Bruce 3 years, 8 months ago.

Topic Author Topic
Posted: Wednesday Apr 24th, 2013 at 3:43 pm #48304

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Friday Apr 26th, 2013 at 12:52 am #48421
Bruce
Username: Bruce
Staff Member

Thank you for your inquiry.

When user updates their profile a webhook is generated so we can run a script
As there is no webhook, how would we capture this action when form is filled and output as JSON?

As you mentioned, there are no API Notifications for Profile Edits, due to the fact that there are no WordPress hooks for Profile Edits. The closest you can get to a WordPress hook for profile edits is edit_user_profile_update, but that hook is only going to work for edits done within the WordPress Dashboard (so not at all).

I’d say the best way to handle this would be to use the s2Member Profile Modifications shortcode, and use the ws_plugin__s2member_during_handle_profile_modifications hook to see when a User changes something in their profile through the s2Member shortcode.

However, in order to make sure things run smoothly we’ll have to disable users from changing their email addresses so Mailchimp doesn’t freak out. How can we do this? (I guess you could hardcode the main profile form and disable input that way, but not particulary graceful).

You noted that email addresses could be used as Usernames. If you did it that way, WordPress won’t allow you to change it.

Is there an advised way of editing the signup/profile forms or are the only options to hardcode or use the defaults?
For instance, a basic thing may be: some custom user data on signup, but not have it display or editable in a users profile

You can use CSS, or you can overwrite this file that powers the Profile Modifications Pro Form:

/s2member/includes/classes/profile-mods-in.inc.php

Can we edit or add on validation rules that won’t be mess up the plugin’s default forms?
For instance, we want to only allow emails as usernames, clone the username in the email form, and validate both as emails

Yes, s2Member uses a JavaScript file (with PHP bits and pieces intermingled for security) to handle validations here:

/s2member/includes/s2member-min.js

The unminified file is in that directory as well.

Bulk update all user info manually or automatically, including all custom fields
Call 3rd party APIs, check what is out of sync (or not yet added), notify user, sync data

You can use s2Member’s Remote Operations API to change things about Users. You can find that here:

Dashboard -› s2Member® -› API / Scripting -› Remote Operations API

Outgoing information needs to be done through API Notifications.

See: Dashboard -› s2Member® -› API / Notifications
See Also: Knowledge Base » Building An API Notification Handler

I’m also considering using Zapier which looks like a great service to hook up different APIs, bit pricey but accepts webhooks. If we can get the profile form working, it could then be processed to any third party service.

It looks like you could set up s2Member with Zapier from the surface. I haven’t ever worked with it, though, so I can’t tell you for sure. If you’re going to work with it you’ll be working with s2Member’s API Notifications.

Posted: Friday Apr 26th, 2013 at 1:37 pm #48507

Thanks Bruce, that gives us a good starting point. The only thing is the Mailchimp stuff:

You noted that email addresses could be used as Usernames. If you did it that way, WordPress won’t allow you to change it.

If we’re using the default Mailchimp S2 Member signups/upgrades, it’ll be using the email field, which is editable — so unless we replaced everything with custom scripts, we’d still need to disable both the username and email (and edit by admin if required). Like I say I guess JS could be used to add “disabled” to the inputs, though perhaps not the best way.

Posted: Friday Apr 26th, 2013 at 8:01 pm #48511
Bruce
Username: Bruce
Staff Member

If we’re using the default Mailchimp S2 Member signups/upgrades, it’ll be using the email field, which is editable — so unless we replaced everything with custom scripts, we’d still need to disable both the username and email (and edit by admin if required). Like I say I guess JS could be used to add “disabled” to the inputs, though perhaps not the best way.

I understand. Thanks for the clarification. This brings up a good point. This will require some custom code, but I believe you could stop the User from changing their email via overwriting the profiles file that I mentioned in my last file, disabling/deleting this field and filtering the POST response that s2Member receives. That’s the only way I see possible.

Viewing 3 replies - 1 through 3 (of 3 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.