2013-11-19, 01:18 PM
Hello.
I'm working to a plugin (for personal use - in MyBB 1.6.11) to hide super admins (defined in "config.php") from all visible sections of my forum. A kind of "invisible super-admin" (please, don't ask me why I need this - I just want to find the better way to do this). I know how to do this with modification of core files but I try to do it with a plugin.
Ok, so... I need a little help with "memberlist.php".
There are 4 hooks:
If I want to hide super admin with id 1 from Member List page, it works if I change "where" condition from this query (line 224):
With a plugin, probably I must to use this hook:
I would be grateful if you give me an idea about how can be excluded a certain user id from memberlist ?.
I'm working to a plugin (for personal use - in MyBB 1.6.11) to hide super admins (defined in "config.php") from all visible sections of my forum. A kind of "invisible super-admin" (please, don't ask me why I need this - I just want to find the better way to do this). I know how to do this with modification of core files but I try to do it with a plugin.
Ok, so... I need a little help with "memberlist.php".
There are 4 hooks:
$plugins->run_hooks("memberlist_start");
$plugins->run_hooks("memberlist_search");
$user = $plugins->run_hooks("memberlist_user", $user); // probably the most important for me in this case
$plugins->run_hooks("memberlist_end");
If I want to hide super admin with id 1 from Member List page, it works if I change "where" condition from this query (line 224):
$query = $db->query("
SELECT u.*, f.*
FROM ".TABLE_PREFIX."users u
LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
WHERE {$search_query}
ORDER BY {$sort_field} {$sort_order}
LIMIT {$start}, {$per_page}
");
while($user = $db->fetch_array($query))
{
$user = $plugins->run_hooks("memberlist_user", $user);
if(!$user['username'])
{
continue;
}
// rest of code ...
with: $query = $db->query("
SELECT u.*, f.*
FROM ".TABLE_PREFIX."users u
LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
WHERE {$search_query} AND u.uid != {$mybb->config['super_admins']}
ORDER BY {$sort_field} {$sort_order}
LIMIT {$start}, {$per_page}
");
while($user = $db->fetch_array($query))
{
$user = $plugins->run_hooks("memberlist_user", $user);
if(!$user['username'])
{
continue;
}
// rest of code ...
With a plugin, probably I must to use this hook:
$user = $plugins->run_hooks("memberlist_user", $user);
but... above query is called before this hook so... I would be grateful if you give me an idea about how can be excluded a certain user id from memberlist ?.