Topic: [Question] Extending moderate.php

I'm trying to extend a function in moderate.php but I can't make it work.
I want a specific user to bypass the permission check at line 92-93.

if ($forum_user['g_id'] != FORUM_ADMIN && ($forum_user['g_moderator'] != '1' || !array_key_exists($forum_user['username'], $mods_array)))
    message($lang_common['No permission']);

So far I tried to:

1) Pushing and unshifting the username of said user into the moderators array at line 88.

$mods_array = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();

2) Setting $forum_user['g_moderator'] == '1' if user matches an if statement.

3) Setting the user group id to 1 (admin) to pretend the user is an admin and therefore succeed the permission check.

4) Changing the if statement entirely using the hooks before and after the statement (both hooks together and one at time).

These attempts were all unsuccessful. Can anyone help?

Thanks in advance.

Re: [Question] Extending moderate.php

Would it not be easier to create a new group - psuedo moderator - and assign permissions via that?

alternatively I'd suggest echo'ing out the $mods_array via the mr_pre_permission_check hook to ensure you are adding the correct information. Then use that same hook at add to the mods_array

my mind is on a permanent tangent
byUsers forum

Re: [Question] Extending moderate.php

Rich Pedley wrote:

Would it not be easier to create a new group - psuedo moderator - and assign permissions via that?

No, that's exactly what I don't want to do smile

Rich Pedley wrote:

alternatively I'd suggest echo'ing out the $mods_array via the mr_pre_permission_check hook to ensure you are adding the correct information. Then use that same hook at add to the mods_array

I'll try, thanks.

Re: [Question] Extending moderate.php

I've printed out the $mods_array before and after pushing my value in and it worked properly (outputting the user name the second time). I've therefore tried to set $forum_user['g_moderator'] to 1 along with the pushed array and it didn't work. The only thing that worked was setting the group id of the user to 1, to pretend the user is a forum admin. I don't know if it's safe, it's surely not the proper way to do it, but it worked.