Skip to Content Skip to Menu

Profile access control

5 years 9 months ago - 5 years 9 months ago #309581 by apurvkolte
Profile access control was created by apurvkolte
Is it possible to run a custom to code to allow or block access to a profile ?

I want to check the user group of profile and viewer, if both are from same group the block the profile access.
Last edit: 5 years 9 months ago by apurvkolte.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8277
  • Karma: 1443
5 years 9 months ago #309603 by krileon
Replied by krileon on topic Profile access control
You can redirect away using CB Auto Actions on the onAfterUserProfileDisplay trigger. I recommend using the after trigger since the displayed user has been set allowing you to do something like the below in the conditions of your auto action.

Left: [cb:if user="#displayed" usergroup includes "2"]REDIRECT[/cb:if]
Operator: Equal To
Right: [cb:if user="#me" usergroup includes "2"]REDIRECT[/cb:if]

If both the displayed and viewing user have the usergroup with an id of 2 it should trigger the action. As for what action to use simply use a Redirect action if you want to redirect away.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

5 years 9 months ago #309618 by apurvkolte
Replied by apurvkolte on topic Profile access control
This works perfectly ! Thanks a lot.

Is there a way to bypass Super admin from this check ? I tried below but its not helping (super admin group is 8)

[cb:if user="#displayed" usergroup includes "10"]REDIRECT[/cb:if]

EQUAL TO

[cb:if user="#me" usergroup includes "10" usergroup !includes "8"]REDIRECT[/cb:if]

Please Log in or Create an account to join the conversation.

5 years 9 months ago #309619 by apurvkolte
Replied by apurvkolte on topic Profile access control
I think below is working (I am still testing all combinations)

I added one more condition

[cb:if user="#me" usergroup !includes "8"]REDIRECT[/cb:if]

EQUAL TO

REDIRECT

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8277
  • Karma: 1443
5 years 9 months ago #309649 by krileon
Replied by krileon on topic Profile access control
You can add an and condition to the substitution. Example as follows.

Left: [cb:if user="#displayed" usergroup includes "2"]REDIRECT[/cb:if]
Operator: Equal To
Right: [cb:if user="#me" usergroup includes "2" and usergroup !includes "8"]REDIRECT[/cb:if]


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum