inherit
245749
0
Dec 13, 2018 4:32:43 GMT -8
tnchuck100
360
June 2017
tnchuck100
|
Post by tnchuck100 on Sept 8, 2017 5:34:46 GMT -8
Considering this code for my Shoutbox is there a line of code I can add to further restrict access to only those that are members of the "Regular member" group? (Regular member is a group I have defined)
{if $[current_user.is_member]} <!-- restrict to members only -->
<div class="$[shoutbox_class] container full">
<div class="title-bar"><h2>Members only chat box</h2></div> <!-- was "Shoutbox" changed 8/15/17 -->
<div class="content">
{if $[welcome_message]}
<div class="pad-all-double content-box shoutbox_welcome_message">
$[welcome_message]
</div>
|
|
#eb7100
1480
0
1
Nov 21, 2024 14:52:33 GMT -8
Craig
209,196
September 2001
cmdynasty
|
Post by Craig on Sept 8, 2017 5:49:52 GMT -8
You could change:
{if $[current_user.is_member]} <!-- restrict to members only -->
to:
{if $[current_user.group.name] == "Regular Member"} <!-- restrict to 'Regular Member' group only -->
|
|
inherit
245749
0
Dec 13, 2018 4:32:43 GMT -8
tnchuck100
360
June 2017
tnchuck100
|
Post by tnchuck100 on Sept 8, 2017 5:54:13 GMT -8
I'll try that. Thanks. Update: I tried it. It does not work.
|
|
#eb7100
1480
0
1
Nov 21, 2024 14:52:33 GMT -8
Craig
209,196
September 2001
cmdynasty
|
Post by Craig on Sept 8, 2017 5:55:14 GMT -8
It should work. Let me know if it does not.
|
|
inherit
245749
0
Dec 13, 2018 4:32:43 GMT -8
tnchuck100
360
June 2017
tnchuck100
|
Post by tnchuck100 on Sept 8, 2017 6:03:59 GMT -8
It should work. Let me know if it does not. It does not work.
|
|
#eb7100
1480
0
1
Nov 21, 2024 14:52:33 GMT -8
Craig
209,196
September 2001
cmdynasty
|
Post by Craig on Sept 8, 2017 6:35:40 GMT -8
Make sure that the group name matches exactly. If it still does not work, could you link to your forum.
|
|
inherit
245749
0
Dec 13, 2018 4:32:43 GMT -8
tnchuck100
360
June 2017
tnchuck100
|
Post by tnchuck100 on Sept 8, 2017 6:49:26 GMT -8
I did. I suspect that since $[current_user.group.name] is not a single entity but an array of values is the problem. A list of groups would have to be evaluated to see if the member was in that list. Link: tncampers.freeforums.net/Man, this Bad gateway is really a problem. Takes multiple attempts at posting now.
|
|
inherit
226544
0
Oct 5, 2018 10:29:39 GMT -8
Ulises
4,881
November 2015
umacklin
Ulises Weirdo
|
Post by Ulises on Sept 8, 2017 8:29:59 GMT -8
tnchuck100 Note that the $[current_user.group.name] is dependent on what group the user has set to display as in his Edit Profile > Settings (tab) > Display Group settings. If you don't want to be dependent on the group name you could also use the group id. $[current_user.group.id] so that would be {if $[current_user.group.id] == "Group ID HERE"} You can find a groups id by clicking on the group link in a user Profile > Groups (tab) and looking at the number after groups= part in the URL. For example, for this forum the Proboards Admin group id is 1.
|
|
inherit
245749
0
Dec 13, 2018 4:32:43 GMT -8
tnchuck100
360
June 2017
tnchuck100
|
Post by tnchuck100 on Sept 8, 2017 8:37:50 GMT -8
That will not accomplish the target. What the display group is cannot affect my desired result. Target is the member MUST be in the specified group to use the shoutbox. I do not require edit capability. Hard coding this group is acceptable. Even if I must determine the group number. But it cannot be dependent of the display group.
There is no looping code that I can insert that will do this?
|
|
inherit
226544
0
Oct 5, 2018 10:29:39 GMT -8
Ulises
4,881
November 2015
umacklin
Ulises Weirdo
|
Post by Ulises on Sept 8, 2017 9:03:00 GMT -8
The group number is determined by the software at the time the group is made, to be clear. Unfortunately what you describe is not possible without letting the users choose what group to display in the layout templates since the user can choose not to display any group at all. The next best thing is placing this in your CSS Style Sheet, at the bottom: .shoutbox.container.full { display: none; } And this code in your global header (or footer): <script> $(document).ready(function () { var current_user_group_ids = proboards.data('user').group_ids; var group_id_allowed_to_access_shoutbox = "GROUP ID HERE"; var is_user_allowed_to_access_shoutbox = $.inArray(group_id_allowed_to_access_shoutbox, current_user_group_ids) != -1; if (is_user_allowed_to_access_shoutbox) { $('.shoutbox.container.full').show(); } });
</script>
That should work regardless of what group they have set to display as the proboards.data('user').group_ids variable is an array full of all the groups the current user is in. Note that this will only work in the desktop version, for now.
|
|
inherit
245749
0
Dec 13, 2018 4:32:43 GMT -8
tnchuck100
360
June 2017
tnchuck100
|
Post by tnchuck100 on Sept 8, 2017 9:11:18 GMT -8
Thanks. I'll play with that.
|
|
inherit
245749
0
Dec 13, 2018 4:32:43 GMT -8
tnchuck100
360
June 2017
tnchuck100
|
Post by tnchuck100 on Sept 8, 2017 16:12:56 GMT -8
Thanks Ulises. This did exactly what I wanted to do.
|
|
inherit
245749
0
Dec 13, 2018 4:32:43 GMT -8
tnchuck100
360
June 2017
tnchuck100
|
Post by tnchuck100 on Sept 8, 2017 17:43:20 GMT -8
UPDATE: I spoke too soon.
Normally when a new page is requested the shoutbox keeps the newest posts visible. With this mod a new page request will reset the shoutbox with the oldest posts showing requiring you to scroll down to the newest each time.
I am new to this kind of coding so I wanted to get your blessing on this before I consider it complete. Is there something I may not be aware of? This change seems to have overcome the side effect above.
I left out the CSS code you proposed in the style sheet and made this change in the global footer:
Added this: else { $('.shoutbox.container.full').hide();
<script>
$(document).ready(function () {
var current_user_group_ids = proboards.data('user').group_ids;
var group_id_allowed_to_access_shoutbox = 22; // 14=Regular member 22=Chat box
var is_user_allowed_to_access_shoutbox = $.inArray(group_id_allowed_to_access_shoutbox, current_user_group_ids) != -1;
if (is_user_allowed_to_access_shoutbox) {
$('.shoutbox.container.full').show();
} else {
$('.shoutbox.container.full').hide();
}
});
</script>
|
|
inherit
226544
0
Oct 5, 2018 10:29:39 GMT -8
Ulises
4,881
November 2015
umacklin
Ulises Weirdo
|
Post by Ulises on Sept 9, 2017 7:48:34 GMT -8
tnchuck100 Does the same thing (the scrolling) happen to you in an incognito window? On my end the latest shouts are automatically shown on the bottom, meaning no scrolling to the new. I even scrolled up and requested a new page and the latest shouts were shown. Try clearing the cache as well. Let me know if this doesn't work.
|
|
inherit
245749
0
Dec 13, 2018 4:32:43 GMT -8
tnchuck100
360
June 2017
tnchuck100
|
Post by tnchuck100 on Sept 9, 2017 8:01:20 GMT -8
I will back track and put back in your code w/o my change and test that. I'll let you know what happens.
However, is there something about my change that would cause a problem?
|
|