I have a multisite with a lot of blogs.
It's an association that has a national main site (the 1st blog) and a lot of regional sub-sites (the other blogs of the multisite).
S2Member is sitewide activated and properly setted up in each blog. The registration is free and we are using the Membership Only option, not Blog Farm.
I need that all the operations related to membership will be done on main site.
So I have already coded all redirects from blogs to main site: eg. registration, login, lost password, member option page... It seemes to be ok.
When an user subscribes, he will automatically subscribe the main site and (optionally) the referring regional blog.
Then on main site (but not in other blogs) the registered user can upgrade to level 1. No more level needed.
I'd like that an user "level-1-on-main-site" can be enter all "level-1" contents of all blogs.
So I need a filter that looks for the s2 level in main site when the plugin checks the s2 level in a blog.
I wrote the following function:
- Code: Select all
function my_check_user_level_fallback ( $level, $vars=array() ) {
if ( is_admin() ) return;
global $blog_id, $user_ID;
if ( $blog_id != 1 && $level == 0 ) {
switch_to_blog ( 1 );
if ( $level == 0 && current_user_is("s2member_level1") ) {
$level = 1;
}
restore_current_blog();
}
return $level;
}
add_filter ("ws_plugin__s2member_user_access_level", "my_check_user_level_fallback", 10, 2 );
It works properly in a post when I get constant (eg. [s2Get constant="S2MEMBER_CURRENT_USER_ACCESS_LEVEL" /]), but it does not when use conditional (eg.[s2If current_user_is(s2member_level1)]You are Level 1[/s2If]). Why?
Then, the hard issue... I have a problem about the automatic redirect to membership option page when a not authorised member try to enter a restricted post: I'd like to have some help about the hooks/code in order make my own level check and follow or cancel the redirect.
Sorry for my bad English, I hope you can understand my problem.
Many thanks for your help.