PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Outside WP application integration

s2Member Plugin. A Membership plugin for WordPress®.

Outside WP application integration

Postby mdelacruzperu » April 12th, 2011, 5:34 pm

Hi. I'm really amazed and pleased of bought s2member pro, it has really nice extra features. Now i have a question I can not find in the forum.
I have wordpress to run a site but I built a custom application to allows users to get some information, I have to give the users access to the application (outside wordpress) only if they have a valid paid subscription in wp and s2member.
Is there a way to integrate this scenery? s2member validating access to an application outside wordpress but in the same domain off course.
User avatar
mdelacruzperu
Registered User
Registered User
 
Posts: 12
Joined: April 12, 2011

Re: Outsite WP application integration

Postby Cristián Lávaque » April 12th, 2011, 5:42 pm

Hola! :)

I'm glad you're happy with s2Member Pro! Jason is definitely doing an awesome job with it.

Regarding your question:

If you want to control the access to the other application, no, s2Member currently works inside WordPress, including the URI Restriction feature.

If you need to give them information regarding this other application, you can do it with a page protected by s2Member in WordPress.

Does that help?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Outside WP application integration

Postby mdelacruzperu » April 12th, 2011, 5:48 pm

Thanks for answering almost inmediately, now I have to add the excellent support to my joy.
Cristian, is it possible to make some ajax call to wordpress from the other side to validate if the user is logged in at wordpress and has the correct subscription in s2ember to allow him access?
User avatar
mdelacruzperu
Registered User
Registered User
 
Posts: 12
Joined: April 12, 2011

Re: Outside WP application integration

Postby Cristián Lávaque » April 12th, 2011, 7:30 pm

I don't know how much of an AJAX wizard you are. Maybe? I don't know that much about AJAX, so I can't tell for sure, sorry. :(

Did you try protecting the script you had under s2Member's file protection and serve it from there? I don't know if it'd work, but you could give it a go. WP Admin -> s2Member -> Download Options.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Outside WP application integration

Postby mdelacruzperu » April 12th, 2011, 7:47 pm

Will try. I was continue checking and saw that s2member can call scripts after certain events. It could help me if you tell me how to call a script when a member is created under certain conditions.
For example is the user creates a free account don't call the script, if the user creates a paid account call the scripts. If a user cancel a paid account call the script, etc.
I know this requires advanced programming but we're ready to deal with that.
Maybe I can use some s2member hooks.
User avatar
mdelacruzperu
Registered User
Registered User
 
Posts: 12
Joined: April 12, 2011

Re: Outside WP application integration

Postby Cristián Lávaque » April 12th, 2011, 8:36 pm

s2Member has plenty of hooks that you can find in the PHP files. Yes, there's the Notifications API which you can read about here WP Admin -> s2Member -> API / Notifications.

This video will help you too.

Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Outside WP application integration

Postby mdelacruzperu » April 13th, 2011, 12:15 pm

I found a way to do this. This is the code on the site outside WP:

Code: Select all
require( '/path_to_wp/wp-load.php' );

if ( is_user_logged_in() ) {
    echo '<pre>';print_r($current_user);echo '</pre>';
}
 else {
    echo 'Please login first';
}
 


It works great, I now have to check the s2 functions to validate the user has a paid subscription. But I have a little problem.

My application is configured to run in a subdomain and the authentication cookie doesn't recognize subdomains. Is there a way in s2member to configure to authentication cookie to be valid for all the domain and not just where wordpress is installed? I mean wordpress is in http://www.myurl.com and the application is in app.myurl.com I need to allow the cookie to work for all the domain myurl.com and all folders.
Last edited by Cristián Lávaque on April 13th, 2011, 8:00 pm, edited 1 time in total.
Reason: Improve code readability. http://www.primothemes.com/forums/viewtopic.php?f=36&t=2780
User avatar
mdelacruzperu
Registered User
Registered User
 
Posts: 12
Joined: April 12, 2011

Re: Outside WP application integration

Postby Cristián Lávaque » April 13th, 2011, 10:19 pm

Nice! Well done for figuring that one out and thanks for sharing it. :)

Regarding subdomains, if you really need to use different ones, you could modify your wp-config.php file.

http://codex.wordpress.org/Editing_wp-c ... kie_Domain

Code: Select all
define('COOKIE_DOMAIN', '.example.com');  


Remove the www and always provide a leading dot. This tells WordPress to set cookies for all sub-domains.

Let me know if that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Outside WP application integration

Postby LarsW » July 29th, 2011, 6:23 pm

mdelacruzperu wrote:I found a way to do this. This is the code on the site outside WP:

Code: Select all
require( '/path_to_wp/wp-load.php' );

if ( is_user_logged_in() ) {
    echo '<pre>';print_r($current_user);echo '</pre>';
}
 else {
    echo 'Please login first';
}
 


It works great, I now have to check the s2 functions to validate the user has a paid subscription. But I have a little problem.

My application is configured to run in a subdomain and the authentication cookie doesn't recognize subdomains. Is there a way in s2member to configure to authentication cookie to be valid for all the domain and not just where wordpress is installed? I mean wordpress is in http://www.myurl.com and the application is in app.myurl.com I need to allow the cookie to work for all the domain myurl.com and all folders.


Sounds great,
But where do I put in the code?

In any of the wp-page or as script somewhere?

Regards / Lars
User avatar
LarsW
Registered User
Registered User
 
Posts: 25
Joined: June 5, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 3 guests

cron