Member categories
ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6
Back to this add-on's main page
View Other Add-ons From Yuri Salimovskiy
Do something if the member has no categories assigned?
General
Mike Mella
|
Posted: 29 June 2016 02:04 PM |
|
|
|
Is it possible to check if the member has no categories assigned to him, and then do something based on that?
|
|
|
Yuri Salimovskiy
|
Posted: 30 June 2016 08:58 AM |
# 1
|
|
Developer
|
You can use {if no_results}...{/if} inside check tag and put your code inside it
|
|
|
Mike Mella
|
Posted: 30 June 2016 09:10 AM |
# 2
|
|
|
I guess what I want to do is say “If the logged in member is assigned the category in the URL *or* no categories at all, do this.” Something like this:
- Member Tinman has category Oz assigned to him. He can see the category “oz” page.
- Member Scarecrow has no categories assigned to him. He can see the category “oz” page.
- Member Dorothy has category Kansas assigned to her. She cannot see the category “oz” page.
Make sense?
|
|
|
Yuri Salimovskiy
|
Posted: 30 June 2016 09:18 AM |
# 3
|
|
Developer
|
Well, you’ll need complex conditional check.
Something like
{exp:member_categories:check member_id="{logged_in_member_id}" category_url_title="{segment_3}"}
Is in {segment_3} category, can see content
{if no_results}
{exp:member_categories:categories member_id="{logged_in_member_id}"} {if count==1} Has some category assigned, cannot see content (count=1 to display it only once) {/if}
{if no_results} Has no categories assigned, can see content {/if}
{/exp:member_categories:categories}
{/if}
{/exp:member_categories:check}
Did not test this myself, but should work
|
|
|