SimplePortal
Support => English Support => Topic started by: Uardo on August 31, 2015, 09:44:58 AM
-
Hello evryone,
I am asking if it is possible to make it so users who are muted cannot shout in shoutbox, they already cannot send PMs or post on boards, would be great if someone can show us a way to make it so they can't shout in shoutbox.
Thank you for your time.
-
Hi Uardo,
I think it has been answered before, but I can't find it at the moment. Basically the way to proceed is to create a membergroup that has *denied* permission to see the shoutbox block, and assign it when necessary.
If you need moderators to be able to assign that membergroup without giving them the "Manage and assign membergroup" permission, you can simply add them as moderators for the banned membergroup.
Hope you don't mind if I move this to Support as coding is not involved ;)
Hint: you can also create a block only visible to the banned membergroup, with some text telling them they have been banned from the shoutbox (which is what I did on my own forum).
Regards
-
Actually creating a membergroup that has denied permission to see the shoutbox block would be a pain and a really hard work, since we have to assign it manually whenever they are muted and remove from membergroup when they are unmuted, i am talking about forums that have over 10,000 users and many of them getting muted daily, imagine having to check everyday if someone is muted or if someone's mute expired.
I am looking for a simple code that would not allow muted users to shout, I don't know much about coding but it should be something like that:
If user muted, not_allowed_to {shout at shoutbox}
I don't know which template to modify, what to replace or add, that's why i am asking!
Regards,
Uardo!
-
And that is unfortunately the same thing I said, it works in the same way :/ The closest thing we have is this: http://simpleportal.net/index.php?topic=11714.0 but I'm pretty sure it's not *exactly* what you want either.
-
You can check if they can send PMs. If they can't send a PM, then reject their shout.
Open /Sources/PortalShoutbox.php
Find:
if (!empty($_REQUEST['shout']))
{
checkSession('request');
is_not_guest();
Replace with:
if (!empty($_REQUEST['shout']))
{
checkSession('request');
is_not_guest();
isAllowedTo('pm_send');
This will result in an fatal error if someone tries to make a shout when they don't have permission to send a pm.
-
Didn't think of that, it could work, even if personally I don't like fatal error thingies.
-
Muted users are not allowed to send PMs. I tried that and it worked, they couldn't shout and i didn't get any error.
I made it so some users couldn't send PMs, and told them to shout while they weren't muted they couldn't but didn't get any fatal error at all.
While you are muted you cannot shout, even that you are allowed to type but when you press enter it keeps reloading (http://puu.sh/jW6rj/5eb9e45060.png) and shout does not appear, is it possible so when you press enter after shouting you will get a message "You are not allowed to shout because you're muted" or something like that, if not no problem!
Thank you for your time and efforts.
Regards,
Uardo
-
Hmm.
In that case, revert my edits above and try this;
Find:
is_not_guest();
Replace with:
is_not_guest();
if (!allowedTo('pm_send'))
{
$_REQUEST['shout'] = '';
$context['can_shout'] = false;
}
Open /Themes/default/PortalShoutbox.template.php
Find:
if (!empty($shoutbox['warning']))
echo '
<li class="shoutbox_warning smalltext">', $shoutbox['warning'], '</li>';
Replace with:
if (!allowedTo('pm_send'))
$shoutbox['warning'] = 'Sorry, but you are banned from using the shoutbox!';
if (!empty($shoutbox['warning']))
echo '
<li class="shoutbox_warning smalltext">', $shoutbox['warning'], '</li>';
-
When i try to add this
if (!allowedTo('pm_send']))
$shoutbox['warning'] = 'Sorry, but you are banned from using the shoutbox!';
Shoutbox and some other blocks does not appear anymore even for users who are not muted.
-
That's strange, try this:
if (allowedTo('pm_send']) == false)
-
Same problem again.
-
You are editing the PortalShoutbox.template.php file right?
-
Yes i am.
It's ok if it cannot be done!
-
Let's try it this way then. Make sure to revert all my previous edits.
Open /Sources/PortalShoutbox.php
Find:
is_not_guest();
Replace with:
is_not_guest();
if (!allowedTo('pm_send'))
{
$_REQUEST['shout'] = '';
$context['banned_from_shoutbox'] = true;
$context['can_shout'] = false;
}
else
$context['banned_from_shoutbox'] = false;
Open /Themes/default/PortalShoutbox.template.php
Find:
function template_shoutbox_embed($shoutbox)
{
global $context, $scripturl, $settings, $txt;
Replace with:
function template_shoutbox_embed($shoutbox)
{
global $context, $scripturl, $settings, $txt;
if ($context['banned_from_shoutbox'])
$shoutbox['warning'] = 'Sorry, but you are banned from using the shoutbox!';
-
I tried it but the warning message "Sorry, but you are banned from using the shoutbox!" does not appear. The good thing is that this time muted users can see shoutbox and other blocks.
The warning should appear just like "Your last shout was less than 2 seconds ago. Please try again later." message but it isn't.
-
Could you check your error log and tell me if you see any undefined indexes for "banned_from_shoutbox"?
-
http://puu.sh/jXaLF/4a68abb107.png
Line 102 is this: if ($context['banned_from_shoutbox'])
-
Sorry, I don't mean to drag this on forever. Revert all previous edits.
Open /Sources/PortalShoutbox.php
Find:
if (!empty($_REQUEST['shout']))
{
Replace with:
// Can they send a PM on the boards? If not, empty out their request...
if (!allowedTo('pm_send'))
$_REQUEST['shout'] = '';
if (!empty($_REQUEST['shout']))
{
This will make any shout they try and make empty.
Open /Themes/default/PortalShoutbox.template.php
Find:
function template_shoutbox_embed($shoutbox)
{
global $context, $scripturl, $settings, $txt;
Replace with:
function template_shoutbox_embed($shoutbox)
{
global $context, $scripturl, $settings, $txt;
if (!allowedTo('pm_send') && $context['user']['is_logged'])
{
$context['can_shout'] = false;
$shoutbox['warning'] = 'Sorry, but you are banned from using the shoutbox!';
}
-
Thank you, really appreciated.
Marking this as solved!
Edit: I just realized that guests can see the warning that muted users see in shoutbox..
-
Adjusted it, forgot that guests can't send PMs lol.
-
Thank you!