|
|
|
Thanks Kati. I totally missed that thread. Have tried the s2-hack option. NOt sure if it’s had any effect, but we’ll see. Thanks for the pointer.
|
|
I have asked a couple of people to kick the tag section hard and they confirm it works. Sweet! Thanks for inspiring the thought processes!
|
|
I think I have done it!! Posting in case I have (it seems to work) and it is useful for someone else…
Using the ‘Member’ tag (this will rely on user discipline to hold-up) I have combined a few things:
Set up a tag.php, tag-subscriber.php and tag-member.php template.
tag.php has the following:
<?php get_header(); ?>
<?php
if (current_user_can('access_s2member_level1')) { get_template_part( 'tag', 'member' ); }
elseif (is_user_logged_in()) { get_template_part( 'tag', 'subscriber' ); }
?>
<?php get_footer(); ?>
Then the two other templates contain the loop pulling the content as I want it, but the tag-subscriber.php template has the following:
<?php while ( have_posts() ) : the_post();
if (has_tag('Member') ) continue;
?>
As far as I can tell, as long as all L1 member resources include the tag ‘Member’ then they will be passed over when the tag archive is generated for a Subscriber. Like I said, the person inputting will have to be disciplined, but from teh testing I have done, it seems to work.
What do you think Raam: am I up another blind alley or may this hold up in the real world?
Thanks
Andy
|
|
Hi Raam
Did you see my post re trying to filter based on an additional tag of Subscriber or Member. Could that work, and if so, how?
Thanks
Andy
|
|
Right, I am trying another approach, but hitting the same difficulties. I thought that if I allow free tagging but insist that either the ‘Subscriber’ tag or ‘Member’ tag is added then I should be able to restrict the tag archive display based on that, but I am still getting all of the posts listed – even the ones that can’t actually be accessed.
How can I get a post that may have multiple tags, but one of which is ‘Member’ not to show up in the listing on the tag archive page that is seen by a Subscriber?
I’m sure it must be do-able, but the examples in the API/Scripting don’t seem to work for this – although I am probably doing something wrong in applying them.
I tried the example 4 you suggested in the loop and outside the loop (can you tell I was not sure how to apply it :-) ) and nothing happened, and I didn’t know what needed changing from the raw example, or what to change it to if it did.
Any help much appreciated.
thanks
Andy
|
|
Scratch that. Success was shortlived. ALl that is doing is listing all posts in that category and not showing the tag archive at all :-(
|
|
Hi Raam
Thanks so much for helping me out. I couldn’t get that example working – not sure what I was doing wrong, but it got me thinking so I had a dig around and I appear to have come up with something that seems to work as far as my testing is showing so far…
<?php
if (current_user_can('access_s2member_level1')) {
query_posts('showposts=10&cat=1,6,7,8,9,10,11,12,13,14,15,16'); }
elseif (is_user_logged_in()) {
query_posts('showposts=10&cat=1,6,7,8,9'); }
?>
My knowledge is pretty limited, but I just applied a bit of (what was in my view, at least) logic and it seems to be filtering the tag listing in accordance with membership rights. Does that sound right to you?
Thanks again! I’d be really grateful if you can tell me if that’s a robust solution, or not, or whether I need to rethink as it isn’t as robust as it seems to be.
Andy
|
|
Ok, I am answering my own question here:
Just used your code in the template and the super-admin sees the right stuff now. I guess I was restricting it by being level specific in my conditional where yours is more open – with the whole can_access thing going on instead of s2member_level thing that I had going on. Good piece of learning for me there – thanks!
Out of interest, what level is a super-admin?
Thanks for getting me out of this dead end Cristian and Cassell – very much appreciated.
Andy
|
|
Thanks for the code Cristian – much neater! I am learning so much in such a short space of time on this project. Properly awesome!
I have nailed the issue. It’s to do with Super-Admin. I created a new user and gave them super-admin on all the sites in the network. Then took super admin off me. Once I did that it all worked for me, but the new super admin gets the ‘you can’t access this’ message.
I am guessing this is to do with my lack of knowledge re network setups, but have I done something wrong?
Thanks for your help!
Andy
|
|
Like you, I have limited knowledge in all of this, but as far as I know the reason the } is followed by a closing of the php statement is that non-php code follows, so you have to close it, put in your html then open a new <?php until you get to the next lot of html.
I think that because I am using all php functions I am OK without doing that.
The conditional itself is working great, it's just not functioning for existing users – it's as if it is not recognizing the S2 Member levels.
I have a meeting this morning but after that I am going to see if assigning a different level to an existing user has any effect to try and isolate if it is just a database thing with membership assignments that needs nudging to change or if it is connected to the user itself. I am hoping not to need to delete and recreate users!
If any of the devs can throw some light on this before I have to do anything drastic, that'd be much appreciated, an in the meantime, once again, thanks for all your input, Cassell
Andy
|
|
Yeah – I have tried it with another user. Same result.
They are spaces, but they don’t seem to affect it running. I usually put them in to help me follow what’s going on, but that may well be the wrong thing to do?
|
|
Thanks Cassell. I really appreciate your help. I have the conditional working perfectly now, but only for new users. Despite my user list showing me as a level 4 member, with this conditional I get the ‘you can’t access this’ message. Yet, for a new user I set up at L4 they see what they should see, as does a user I set up at L1. If Christian or Raam can help ith highlighting what I am doing wrong there, that’d be fantastic.
Cassell, once again, thanks for steering me in the right direction and taking the time to respond. For anyone who may be interested, here is te conditional that now works:
<?php if (current_user_is("s2member_level4")){
wp_nav_menu (array ("theme_location" => "resources-level-1"));
wp_nav_menu (array ("theme_location" => "resources-level-2"));
}
else if (current_user_is("s2member_level3")){
wp_nav_menu (array ("theme_location" => "resources-level-1"));
wp_nav_menu (array ("theme_location" => "resources-level-2"));
}
else if (current_user_is("s2member_level2")){
wp_nav_menu (array ("theme_location" => "resources-level-1"));
wp_nav_menu (array ("theme_location" => "resources-level-2"));
}
else if (current_user_is("s2member_level1")){
wp_nav_menu (array ("theme_location" => "resources-level-1"));
wp_nav_menu (array ("theme_location" => "resources-level-2"));
}
else if (current_user_is("s2member_level0")){
wp_nav_menu (array ("theme_location" => "resources-level-1"));
}
else { ?>
You can't access this
<?php }
?>
This was executed after first following the instructions here: http://www.primothemes.com/forums/viewtopic.php?t=707&p=54152 to register the menus.
I can’t figure out why I am having issues with existing users, though. So, any help from anyone with that would be much appreciated.
Cheers
Andy
|
|
Now here’s a twist. Created a new user with L4 and that user sees what they should see. It seems to be with existing members that I am having the issue. Weird. Any thoughts?
|
|
Thanks Cassell. I thought I’d cracked it when I followed your link, but I must be doing something very wrong.
My S@ Member level is 4, but I get the ‘else’ result when I try this:
<?php if (current_user_is("s2member_level4")){
wp_nav_menu (array ("theme_location" => "resources-level-2"));
}
else if (current_user_is("s2member_level3")){
wp_nav_menu (array ("theme_location" => "resources-level-2"));
}
else if (current_user_is("s2member_level2")){
wp_nav_menu (array ("theme_location" => "resources-level-2"));
}
else if (current_user_is("s2member_level1")){
wp_nav_menu (array ("theme_location" => "resources-level-2"));
}
else if (current_user_is("s2member_level0")){
wp_nav_menu (array ("theme_location" => "resources-level-1"));
}
else { ?>
You can't access this
<?php }
?>
I know you said you aren’t a tech, but you are doing a great job of helping me out, so if you have anything you can throw on why this isn’t working, it’d be much appreciated :-)
Thanks for your help!
Andy
|
|
Hi Cassell
Thanks for stepping in!
That is something I wondered about doing – I thought maybe I was trying to be too clever using the wp_navs, but I still couldn’t find anywhere how to set the conditional based on member level.
I’m guessing if I could get the conditional to work for teh way you suggested it ought to work for the alternative, but I am utterly stumped.
How did you make the conditional work?
|