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.

Blocking Content on a Multisite Subblog

Home Forums Community Forum Blocking Content on a Multisite Subblog

This topic contains 7 replies, has 2 voices. Last updated by  George Fourie 3 years, 5 months ago.

Topic Author Topic
Posted: Wednesday Jul 31st, 2013 at 11:57 am #54515

I have S2member installed on my WordPress Multisite Network.

I only have the plugin active on the main site and not network activated for the network to use.

How can I restrict content on one subblog, where S2member is not active.

So S2member is active on A.subblog.com
and I want to block content on B.subblog.com where S2member isnt active.

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Wednesday Jul 31st, 2013 at 12:03 pm #54516
Moderator

This is the simplest way to handle that. Please see this API Function in the s2 Codex.

See also: http://codex.wordpress.org/Function_Reference/current_user_can_for_blog

Posted: Wednesday Jul 31st, 2013 at 12:13 pm #54518

ok, so create a function in the functions file?

Posted: Wednesday Jul 31st, 2013 at 12:13 pm #54519

and is that the only way?

Posted: Wednesday Jul 31st, 2013 at 12:37 pm #54520
Moderator

and is that the only way?

Yes, because if s2Member® is not even running there, you won’t have it’s functionality. However, you can use WordPress® itself to test permissions across blogs and that works just fine.

So for instance, you might have an MU plugin file that looks something like this.

Please create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
(NOTE: these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins)
(See also: http://www.s2member.com/kb/hacking-s2member/)

<?php
add_action('wp', 'my_custom_security_gate');
function my_custom_security_gate()
	{
		if(get_current_blog_id() === 2)
			if(is_page(123) && !current_user_can_for_blog(2, 'access_s2member_level1'))
				wp_redirect(home_url('/my-checkout-options/')).exit();
	}
Posted: Wednesday Jul 31st, 2013 at 12:40 pm #54521

ok excellent, now if I’m blocking content within a post, would I use shortcode for it or something?

Posted: Wednesday Jul 31st, 2013 at 2:28 pm #54527
Moderator

If s2Member® were running on that child blog you could use Shortcode Conditionals made possible by s2Member®. Since it sounds like it won’t be, I would suggest that you run ezPHP (also developed by us); and this will make it possible to do something like this inside a Post or Page.

<?php if(current_user_can_for_blog(2, 'access_s2member_level1')){ ?>
	Content goes here.
<?php } else { ?>
	I'm sorry, but you do not have access yet.
<?php } ?>

See: Knowledge Base » ezPHP Plugin for WordPress®
See also: Knowledge Base » Simple Shortcode Conditionals

Posted: Wednesday Jul 31st, 2013 at 9:17 pm #54548

That’s awesome thanks for the help, especially adding the code as well that’s great!

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