Make the visibility of other user's avatar depend. on status of your own avatar

4 years 11 months ago - 4 years 11 months ago #312034 by erichburkhard
Hi - I wanted to implement the following requirement:

Requirement:
1) If the avatar picture of the logged in user (e.g. Cleo: ID = 3129) has been approved, he is allowed to see also the approved avatars pictures of other registered useres (in userlist search and corresponding profiles as well).
2) If the avatar picture of the logged in user (e.g. Cleo: ID = 3129) has NOT been approved yet, he is not allowed to see the avatar pictures of the other users (in userlist seearch and corresponding profiles as well).
3) The profile visibility of the logged in user himself (e.g. Cleo: ID = 3129) should not be affected by the rules 1) und 2)

In order to implement this, I set up the conditional rules of the the avatar field:

Used Plugin: CB Conditional
Used Field: avatar field

******************************************************************

Display: Field conditional hide


Condition 1:

Field: Value
Custom Value: [cb:userdata field="user_id" user="#displayed"/]
Translate Custom Value: No
Operator: Not Equal To
Value: [cb:userdata field="user_id" user="#me"/]
Translate Value: No

Locations:
Registration: No
Profile Edit: No
Profile View: Yes
UserList Search Yes
Userlist View: Yes


AND


Condition 2:

Field Value
Custom Value: 1
Translate Custom Value: No
Operator: Not Equal To
Value: [cb:userdata field="avatarapproved" user="#me"/]
Translate Value: No

Locations:
Registration: No
Profile Edit: No
Profile View: Yes
UserList Search Yes
Userlist View: Yes

Now lets discuss the results of the above two conditions in Detail:

….If the logged in user (Cleo) looks as his own profile (ps: his avatar has not yet been approved) it looks like the following which is 100% correct:



...If the logged in user (Cleo) does a user list search …..it looks as follows….. the result is partially correct….Cleo can't see the (available) avatars of the other users, but the problem is, Cleo can also not see the (black) icon of his own profile (which represents the pending approval)



…If the logged in user (Cleo) does a user list search, and chooses one of the available profiles the result is partially correct....Cleo can't see the (available and approved) avatar of the selected user (Mery) ...which is correct ..., but the problem is again, that the (black) icon of this own profile has disappeared again



Can you please tell me how to set up the conditions correctly? Regards
Attachments:

Please Log in to join the conversation.

4 years 11 months ago #312038 by krileon
You're checking against #displayed which only works when viewing an actual profile. It doesn't work anywhere else. It however is not necessary in CB Conditional since the default substitution user is always the profile being viewed. So the below change should fix that issue.

FROM: [cb:userdata field="user_id" user="#displayed"/]
TO: [user_id]

Regarding it not displaying the field at all that's working as intended. It completely suppresses the fields output. So it's not going to show anything at all. The only way to change this is to use the fields layout parameters and override its display from there. This can be done by editing the avatar field within CB > Field Management then using IF substitutions in the various layouts. Example as follows.

Profile Value Layout:
[cb:if user_id="myid"][value][cb:elseif user="#me" avatarapproved="1"][value][/cb:elseif][cb:else]<img src="[cb:config param="live_site" /]/components/com_comprofiler/plugin/templates/default/images/avatar/nophoto_n.png" class="cbImgPict cbFullPict img-thumbnail" />[/cb:else][/cb:if]

Userlist Value Layout:
[cb:if user_id="myid"][value][cb:elseif user="#me" avatarapproved="1"][value][/cb:elseif][cb:else]<a href="[cb:url location="profile_view" /]"><img src="[cb:config param="live_site" /]/components/com_comprofiler/plugin/templates/default/images/avatar/tnnophoto_n.png" class="cbImgPict cbThumbPict img-thumbnail" /></a>[/cb:else][/cb:if]

That should allow the field to display if the profile owner is the viewing user or the viewing user has an approved avatar. Otherwise it'll display the custom HTML for a default avatar image. The userlist output should still link to their profile as well.


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.
The following user(s) said Thank You: erichburkhard

Please Log in to join the conversation.

4 years 10 months ago - 4 years 10 months ago #312142 by erichburkhard
In my spec (see history) I have forgotten to add the following condition:

"A certain user is also not allowed to see other pics (in profile and user list as well) if his own avatar has been declined by the moderator. After such a decline of the avatar photo by the moderator the db record shows the following content:

avatar = NULL
avatarapproved = 1

Can you help me to implement this additional condition in your 'Profile Value Layout' & 'User List Value Layout' - if-statement? I tried it but I don't know the correct syntax

regards

Please Log in to join the conversation.

4 years 10 months ago #312147 by krileon
You'd just need to adjust the following case.

From: [cb:elseif user="#me" avatarapproved="1"]
To: [cb:elseif user="#me" avatar!="" and avatarapproved="1"]

This would ensure they have an avatar and it's approved.


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 to join the conversation.

4 years 10 months ago #312165 by erichburkhard
Hi - after the correction the two if statements look as follows:

Profile Value Layout:

[cb:if user_id="myid"][value]
[cb:elseif user="#me" avatar!="" and avatarapproved="1"][value]
[/cb:elseif]
[cb:else]<img src="[cb:config param="live_site" /]/components/com_comprofiler/plugin/templates/default/images/avatar/nophoto_n.png" class="cbImgPict cbFullPict img-thumbnail" />
[/cb:else]
[/cb:if]


User List Value Layout:

[cb:if user_id="myid"][value]
[cb:elseif user="#me" avatar!="" and avatarapproved="1"][value]
[/cb:elseif]
[cb:else]<a href="[cb:url location="profile_view" /]"><img src="[cb:config param="live_site" /]/components/com_comprofiler/plugin/templates/default/images/avatar/tnnophoto_n.png" class="cbImgPict cbThumbPict img-thumbnail" /></a>
[/cb:else]
[/cb:if]

The problem I still have is when the moderator declined the avatar of certain user x. If this user x logs in it is still possible for him to see all the avatars of the other members in the userlist. I don't understand why, because after a decline the field values of user x (in the database) are as follows:

avatarapproved = 1
avatar = NULL

based on this the statement: [cb:elseif user="#me" avatar!="" and avatarapproved="1"] should correctly evaluate to FALSE !?! ...or is NULL not the same as ""?

regards

Please Log in to join the conversation.

4 years 10 months ago #312172 by krileon
It maybe due to the PHP output of the avatar field returning the empty avatar image URL instead of empty string. Try the below.

From: [cb:elseif user="#me" avatar!="" and avatarapproved="1"]
To: [cb:elseif user="#me" avatar!~"/nophoto_n\.png/" and avatarapproved="1"]


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.344 seconds

Facebook Twitter LinkedIn