Page 1 of 1

Outside WP application integration

PostPosted: April 12th, 2011, 5:34 pm
by mdelacruzperu
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.

Re: Outsite WP application integration

PostPosted: April 12th, 2011, 5:42 pm
by Cristián Lávaque
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?

Re: Outside WP application integration

PostPosted: April 12th, 2011, 5:48 pm
by mdelacruzperu
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?

Re: Outside WP application integration

PostPosted: April 12th, 2011, 7:30 pm
by Cristián Lávaque
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.

Re: Outside WP application integration

PostPosted: April 12th, 2011, 7:47 pm
by mdelacruzperu
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.

Re: Outside WP application integration

PostPosted: April 12th, 2011, 8:36 pm
by Cristián Lávaque
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.


Re: Outside WP application integration

PostPosted: April 13th, 2011, 12:15 pm
by mdelacruzperu
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.

Re: Outside WP application integration

PostPosted: April 13th, 2011, 10:19 pm
by Cristián Lávaque
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. :)

Re: Outside WP application integration

PostPosted: July 29th, 2011, 6:23 pm
by LarsW
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