MyBB Community Forums

Full Version: Simple plugin causes "Content Encoding Error"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I took a stab at making my first plugin as a way to remove a specific user from the memberlist page in a way that would be persistent through upgrades.  The plugin is very simple:

<?php
if(!defined("IN_MYBB"))
{
    die("You Cannot Access This File Directly.");
} 

$plugins->add_hook('memberlist_user', 'remove');

function memberlistmod_info()
{
    return array(
        "name"          => "Memberlist Mods",
        "description"   => "Custom modifications for the memberlist",
        "website"       => "",
        "author"        => "",
        "authorsite"    => "",
        "version"       => "1.0",
        "guid"          => "",
        "compatibility" => "*"
    );
}

function remove($current_user)
{
 if ($current_user['uid'] == 3) {$current_user['username'] = '';}
 return $current_user;
}

?>

Since the next lines in memberlist.php "continue" if the username isn't set, this removes that member from the list.

The problem is that activating the plugin causes the entire forum, except for the ACP, to return the following error:
Quote:Content Encoding Error

The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.

Please contact the website owners to inform them of this problem.

I tried commenting out everything in the plugin code other than the IN_MYBB check and the info function, but it still causes the error. Disabling gzip does fix the problem, but I can't for the life of me figure out how activating what is essentially a blank plugin causes gzip to suddenly not work (but the ACP is immune?!?!?).

If anyone has any ideas what could cause this (or has a more elegant solution to remove the member from the memberlist), please let me know. Thanks in advance!

Other possibly relevant info:

MyBB Version - 1.6.13
PHP Version - 5.3.22
SQL Engine - MySQLi 5.1.57
Webserver - IIS 7.5
Try this

function remove($current_user)
{
 if ($current_user['uid'] == 3) { $current_user['username'] = ''; }
 return $current_user;
}

While it doesn't look different, it may be because it didn't like that there was no space after the semicolon or the braces.
(2014-09-22, 05:18 PM)dragonexpert Wrote: [ -> ]Try this


function remove($current_user)
{
 if ($current_user['uid'] == 3) { $current_user['username'] = ''; }
 return $current_user;
}

While it doesn't look different, it may be because it didn't like that there was no space after the semicolon or the braces.

Gave it a shot, but no dice. Undecided
referred code is working without any changes on a local test forum (MyBB 1.8)
not noticed any issues and gzip level set at 4 (also tested at level 9)
Just to follow up, I got this working by opening a functional plugin, replacing all the code with my custom memberlistmod code, then overwriting the memberlistmod.php file. Presumably, there was some issue with the way the text in the file itself was coded that the gzip functions didn't like.

Thanks for the suggestions! Smile