HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


[Resolved] Using "if_in_group"

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#106098 (In Topic #20696)
Avatar

Honoured member

I'm using the "if_in_group" command and I can get it work properly for the first group I list, but ultimately I'd like to designate more than one group and for some reason, it doesn't work for the second group?

I suspect it's likely just a matter of syntax, but I've tried a couple of variants and it still doesn't work?  Here's the code as it stands right now:

{if_in_group="Administrators";"Novice Poster" type="primary"]Yet another test[/if_in_group}

(Yes, I changed the end brackets above on purpose so I could post this message. otherwise it wouldn't allow me to post.)

Thanks very much :$


Last edit: by superiorpyro
Back to the top
 
Posted
Item has a rating of 5 (Liked by superiorpyro)  
Rating:
#106103
Avatar

Fan in action

I'm wondering if coding primary is your problem.

I'm relatively new to command/code so not sure that what you are is using tempcode. I have found IS_IN_GROUP as per (should you perhaps be using IS instead of IF?):

Code

{IS_IN_GROUP,1-3}


Which has:

ocPortal Tutorial: Tempcode Programming said

Find whether the current member is in a usergroup (parameters together constitute an ocFilter list, except if the last is primary or secondary then this specifies that the check be limited to checking such usergroup membership)


This indicates that primary restricts the search to the user's primary group (and thus only 1 group), which appears to be the issue you are experiencing. However, again, I'm not sure because of IF versus IS.


Last edit: by Miket

Regards, Mike.
Back to the top
 
Posted
Item has a rating of 5 (Liked by superiorpyro)  
Rating:
#106157
Avatar

Tempcode (which works within Comcode too):

Code

{+START,IF,{$IS_IN_GROUP,1,2,3}}
You're in groups either #1, or #2, or #3.
{+END}

Comcode:

Code

[if_in_group="1,2,3"]
You're in groups either #1, or #2, or #3.
[/if_in_group]

Or in Comcode you're allowed to use usergroup names too:

Code

[if_in_group="Axe murderers,Maniacs,One Direction Fans"]
You're in groups either Axe murderers, Maniacs, or One  Direction Fans
[/if_in_group]


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Item has a rating of 3 (Liked by superiorpyro)  
Rating:
#106158
Avatar

I just took a look at the Comcode Tag Assistant, and I can see it makes it a bit over-complex. As you can see above, ocFilter in the simplistic case, is just a comma-separated list.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#106176
Avatar

Honoured member

Thanks Chris, I prefer the comcode and although I thought I'd tried the comma separated values maybe I had only tried colon and semi-colon with the actual user group names.
I've updated the syntax and it works like a charm!
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: