Hiding certain content from certain members
Posted: 28 June 2008 06:10 PM   [ Ignore ]  
Summer Student
Total Posts:  10
Joined  02-20-2008

Hello,

Was wondering if someone of you wonderful EE experts out there could help me with my beginner level problem… I am trying to hide certain content from visitors logged in with group_id == ‘3’ and to hide even more content from visitors not logged in at all. Below is the best I got so far, but it doesn’t work, of course. Any help would be super nice!

{exp:weblog:entries orderby="date" sort="desc" limit="1" weblog="{my_weblog}"}
{categories}
{if logged_out}{categories show
="not 5|6"}
{if
:elseif group_id == '3'}{categories show="not 6"}
{
/categories}
{if
:else}{content}
{
/if}
{
/exp:weblog:entries}

Profile
 
 
Posted: 28 June 2008 09:54 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRank
Total Posts:  1994
Joined  05-07-2007

MeCasper:


How about:

{if logged_in}
    {exp
:weblog:entries orderby="date" sort="desc" limit="1" weblog="{my_weblog}"}
        {if member_group
== "3"}
            {categories show
="not 6"}
            {
/categories}
        {if
:else}
            {categories show
="not 5|6"}
            {
/categories}
        {
/if}
    {
/exp:weblog:entries}
{if
:else}
    {exp
:weblog:entries orderby="date" sort="desc" limit="1" weblog="{my_weblog}"}
        {categories show
="not 5|6"}
        {
/categories}
    {
/exp:weblog:entries}
{
/if}

So basically, you would be first checking to see if the member is logged in.  If they are a member of group 3, then show them what you should, if not, show them what a non-logged in user would see.  Then if they are not logged in, they are logged out, so show them what you want to.

Hope that helps and works for you!  grin

-greg

 Signature 
Profile
MSG
 
 
Posted: 29 June 2008 07:51 AM   [ Ignore ]   [ # 2 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23528
Joined  05-20-2002

Depends- do you not want to show entries at all if they are in certain cats and the member level differs?  If so- you want to change the actual weblog parameters- a la Greg A. above.

If you want to show everyone the entries- but vary what bits of the entries they see (only see the links to categories a,b,c if member, and/or only see the full body content if member)- then you’d want a single weblog tag and vary up the bits shown.

If that doesn’t help- layout in detail what you’re going for- per member group, what should each see?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 29 June 2008 03:39 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  10
Joined  02-20-2008

Thank you very much for your replies! The code that Greg A. suggested worked fine after a bit of tweaking! It was exactly what I was looking for!

I’m very thankful for that, but now I ran into an unexpected problem- if the entry isn’t published with a category at all, it doesn’t show up. I could solve it by telling the client always to tag an entry with a category, but probably they won’t always remember to do it. That’s why I originally tried to make the publishing as simple as possible- if an entry is meant for anyone to see, no category needed, just publish. If an entry is meant for one of the two specific member groups, then a category is added, and logging in is needed to see it.

Is it then so that after the {categories} tag is used in EE, it only cares about entries with a category added and disregards and doesn’t show the other entries that are without a tag? Below is the final code that worked otherwise. Note that the {content} tag, which is my main content is between the {categories} tag. Does that make a difference?

{if logged_in}
    {exp
:weblog:entries orderby="date" sort="desc" limit="1" weblog="{my_weblog}"}
        {if member_group
== "3"}
            {categories show
="not 6"}
                {content}
            {
/categories}
        {if
:else}
                {content}
        {
/if}
    {
/exp:weblog:entries}
{if
:else}
    {exp
:weblog:entries orderby="date" sort="desc" limit="1" weblog="{my_weblog}"}
        {categories show
="not 5|6"}
            {content}
        {
/categories}
    {
/exp:weblog:entries}
{
/if}

Profile
 
 
Posted: 30 June 2008 03:58 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  10
Joined  02-20-2008

I just wanted to reply to my own newbie question and to close this one off:

Apparently, if you are displaying entries between the {categories}{/categories} tags, the entries that haven’t been assigned to a category don’t show up at all. This was a bit confusing for me- but, easy to solve by assigning a default category to the weblog you are going to publish to. This can of course be done in the administrative preferences of a weblog.

Profile
 
 
Posted: 30 June 2008 04:08 PM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12390
Joined  04-29-2002

In that case, I’m going to close the thread…

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64939 Total Logged-in Users: 57
Total Topics: 81911 Total Anonymous Users: 52
Total Replies: 440322 Total Guests: 299
Total Posts: 522233    
Members ( View Memberlist )