Page 1 of 1

Protecting my subdirectory site?

PostPosted: December 24th, 2011, 3:37 am
by anointed
I have a subdirectory wordpress 3.4beta setup running.
I installed s2members and filled out every configuration available.

Under 'uri' protection I added /support/ to level +1 which is the directory that my support blog resides.

root.com = primary site
root.com/support/ = support network site

No matter what I try, all users are still able to access this subdirectory site.

What in the world am I missing?

I simply want to block access to all resources on my network support site to all members/public who are not level +1 or greater. simple enough?

thnx

*If I can make a suggestion:
I've got to imagine that there would be a number of people who simply want to use s2members to protect one site on their network (i.e. providing support only to paying customers), yet there is no docs anywhere readily available.

Re: Protecting my subdirectory site?

PostPosted: December 24th, 2011, 10:31 am
by Raam Dev
Have you by any chance tried this same setup using WordPress 3.3? It's possible the problem is related to code changes in WordPress 3.4beta that haven't been made compatible in the latest version of s2Member.

Re: Protecting my subdirectory site?

PostPosted: December 24th, 2011, 3:01 pm
by anointed
Yes, I have also tried 3.3, there is no difference.
I spent the entire evening reading through the actual code and I believe the problem lies in that one blog on the network cannot control settings for another blog. (I am using multisite subdirectory setup)

My best guess is that there is no REAL network support with s2members yet. Yeah, the plugin can activate and be activated to run separately on each blog in the network, but other than that, they all seem to operate independently.

My primary blog uri restrictions have no effect on another site in the network, as I described in my opening topic.

I'll create a few separate topics in the forums to describe each problem independently.

Re: Protecting my subdirectory site?

PostPosted: December 24th, 2011, 10:20 pm
by Harty

Re: Protecting my subdirectory site?

PostPosted: December 24th, 2011, 11:08 pm
by anointed
@Harty
thanks for the link, but that is a totally different situation from what I am asking for.

The 'folder' I am trying to protect is simply a 'child-blog' on a multisite wordpress network install.
Jeff answered me in another thread, and unfortunately it looks like s2members isn't really setup for WordPress multisite unless you are talking about running a blog farm. :(

Re: Protecting my subdirectory site?

PostPosted: December 24th, 2011, 11:24 pm
by Harty
Oh well.

Re: Protecting my subdirectory site?

PostPosted: December 26th, 2011, 5:56 am
by Cristián Lávaque
anointed wrote:they all seem to operate independently.

My primary blog uri restrictions have no effect on another site in the network


This is correct. s2Member in a multisite network will work within the scope of each blog, not across them. So the restrictions from one won't work in another, even if you try it from the main blog.

Have you looked at the Multisite User Management plugin? Maybe it can be used combined in some way with s2Member to accomplish what you want? http://wordpress.org/extend/plugins/mul ... anagement/

Re: Protecting my subdirectory site?

PostPosted: December 26th, 2011, 7:02 am
by anointed
Yes I am very familiar with that plugin and was actually working with the author on a project prior to my coming to s2members.

That brings up a good question:

Scenario:
1. I use s2members to protect my entire 'secondary blog' site to all users not level+1 or greater.

2. I use woocommerce to sell a digital product. When the product is sold there is a hook I can tie into 'order_status_completed'
--I then add an action to the multisite user management plugin to add that user to my s2members 'secondary blog' membership blog with the proper role.

*there would be an opportunity for s2members to market a woocommerce paid module here by replacing the digital download system used by woocommerce which sucks, with the much better s2members system*

3. When that fires woothemes adds metadata to the user
Code: Select all
add_action('woocommerce_order_status_completed', 'woocommerce_paying_customer');

function woocommerce_paying_customer( $order_id ) {

$order = &new woocommerce_order( $order_id );

if ( $order->user_id > 0 ) update_user_meta( $order->user_id, 'paying_customer', 1 );
}

source https://github.com/woothemes/woocommerc ... s.php#L409

that gives me a couple of things to work with.
1. The users role becomes 'customer'
2. The user_meta adds 'paying_customer'
3. The multisite user manager plugin adds the customer to my s2members 'secondary blog' with role 'level+1'

Given those tools, I now have all the pieces outside of s2members to differentiate a user who has purchased a product from a regular user, and the user is added to my 'secondary blog' members blog.

I can easily add an action to change the user_role to 'level-1' upon achieving 'paying_customer'.

Is assigning user level-1 all that is required for s2members to then kick in and allow access to the member?
Or is there other data that also must be checked/saved?

**If that is all that is required, could you ask Jason or one of the devs to give me a quick action snippet that I can add to woocommerce which I can hook to 'order_status_completed' which will tie s2members together?

This seems to be the most simple way around the current weakness in s2members network mode.

Benefits:
1. I get to use a great free shopping cart
2. I get the full benefits of s2members protecting 'secondary blogs'
3. OPens up an entire new area for s2members by adding woocommerce

Re: Protecting my subdirectory site?

PostPosted: December 27th, 2011, 4:12 am
by Cristián Lávaque
Good points.

Here's a post by Jason on how to add/remove s2Member roles/capabilities with PHP. It may help you see how you can achieve what you suggested. viewtopic.php?f=36&t=2599

I'll email Jason a link to your post in case he has something to add.

Thanks! :)

Re: Protecting my subdirectory site?

PostPosted: December 30th, 2011, 4:41 pm
by Jason Caldwell
Thanks for the heads up on this thread.
Is assigning user level-1 all that is required for s2members to then kick in and allow access to the member?
Or is there other data that also must be checked/saved?

**If that is all that is required, could you ask Jason or one of the devs to give me a quick action snippet that I can add to woocommerce which I can hook to 'order_status_completed' which will tie s2members together?
That's what it looks like to me. I would do something like this.
Code: Select all
<?php
add_action
('woocommerce_order_status_completed', 'woocommerce_paying_customer');
function woocommerce_paying_customer($order_id)
    {
        if(is_object($order = &new woocommerce_order($order_id)) && !empty($order->user_id))
            {
                update_user_meta($order->user_id, 'paying_customer', 1);
                
                $user 
= new WP_User($order->user_id);
                $user->set_role("s2member_level1");
                /**/
                /* Or, do this if the Role clashes. */
                // $user->add_cap("access_s2member_level0");
                // $user->add_cap("access_s2member_level1");
            }
    }
?>