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.

Pass S2member ID to embedded webapp

Home Forums Community Forum Pass S2member ID to embedded webapp

This topic contains 1 reply, has 2 voices. Last updated by  Andrew Peacock 3 years, 10 months ago.

Topic Author Topic
Posted: Thursday Feb 28th, 2013 at 6:02 pm #43438
Tammy A
Username: tammyaudette

Hello! New user here, I purchased S2Member Pro and I’m hoping someone can help me with an integration issue.

I have a web app that I am building with a program called Application Craft, it allows me to embed the app (html/javascript base) in a website. The app is hosted with Application Craft, I just insert a URL in my wordpress page to the js file they host. The web app collects data. It’s your basic CRUD database program.

I need to pass the wordpress/s2member userID to this app in order for the database record to include the userID.

I can’t figure out if this is possible. I’ve looked at the documentation and tried variation of , but I’m stumped.

Has anyone every done this before? Would really appreciate the help. Not sure where to go from here.

Thanks!

Tammy

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Friday Mar 1st, 2013 at 5:06 am #43454

Hi Tammy,

Application Craft rocks! I’d not heard of it before, so thanks for sharing :-)

So…

To get the user ID from S2, use the PHP constant S2MEMBER_CURRENT_USER_ID

You’ll need to expose that to the HTML so you can embed the code from Application Craft:

<script src="http://ayb.applicationcraft.com//live/userlive.js" type="text/javascript"></script>
<script type="text/javascript">
   waInitForm("APP_CODE_GOES_HERE", 
     757, 811, "id=ID_GOES_HERE");
</script>

The only way I know of doing that in WP is to use a plugin like Allow PHP in Posts and Pages, Shortcode Exec PHP, or Shortcode Exec PHP

Which will end up like this

<script src="http://ayb.applicationcraft.com//live/userlive.js" type="text/javascript"></script>
<script type="text/javascript">
   waInitForm("APP_CODE_GOES_HERE", 
     757, 811, "user_id=<?php echo S2MEMBER_CURRENT_USER_ID; ?>");
</script>

Then, in Application Craft, go to the Code view and you can get the user id like this:

var user_id = app.getInputParameters("user_id");

After that, it’s up your specific app what it does with the ID, so i can’t help with that bit, sorry.

One thing to think about – what’s to stop me using that same HTML and just swapping the ID’s about until I find someone else’s data? The answer is “nothing” at the moment, so it might be worth thinking about an additional key that is passed between S2Member and ApplicationCraft, and use AC’s SSJ (Server-side Javascript) to validate that key.

Hope that helps,
Any

Viewing 1 replies (of 1 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.