MyBB Community Forums

Full Version: Account Switcher: Hide accounts of specific groups from account selection list.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello! I'm working on setting up a forum for some friends, which is an rp forum. What they would like is the ability for a character (a user account, in this case) to not show in the dropdown list or on the post switcher if they fall under a particular group, but to still show in the list of attached users on the attach page.

Is there a way to set this up? Due to the nature of the website, some people may play many characters. However if a character were to become no longer usable or were to "leave" the game, per say, it should no longer appear in drop downs but should still show as a linked account to indicate the master account is the writer.

I did try the fixes from here: https://community.mybb.com/thread-207395...t+switcher
I found the solution through some digging. This will only hide accounts in the drop down of as_header and possibly in the sidebar. They will still appear on the accountswitcher.php page and in account lists under the members.php page.

To hide accounts with X group (in this case, groups 8 and 9) from the master account in the as_header list: locate as_functions.php, find this bit near line 67:
 // Get all attached accounts
                foreach ($accounts as $key => $account) {
                    $attachedPostUser = htmlspecialchars_uni($account['username']);
                    $userUid = (int)$account['uid'];
                    $userAvatar = $eas->attached_avatar($account['avatar'], $account['avatardimensions']);

Insert beneath it to hide the groups desired from the master account, replacing the (x,y) in the array with the groups you do not wish to show, or replacing the whole array with the desired group id number :
if (is_member(array(x,y), $account['uid'])) continue;



Further, to hide this from other attached accounts, near line 237, find this bit of code:
// Get all attached accounts
                    foreach ($accounts as $key => $account) {
                        $userUid = (int)$account['uid'];
                        $attachedPostUser = htmlspecialchars_uni($account['username']);
                        $userAvatar = $eas->attached_avatar($account['avatar'], $account['avatardimensions']);

                        // Leave current user out
                        if ($account['uid'] == $mybb->user['uid']) {
                            continue;
                        }

Similar to above, insert this beneath it to hide the account ids desired, replacing the (x,y) in the array with the groups you do not wish to show, or replacing the whole array with the desired group id number:
if (is_member(array(x,y), $account['uid'])) continue;



And lastly, to hide it from the post author section on new replies/threads, find this code near line 504:
// Get all attached accounts
                        foreach ($accounts as $key => $account) {
                            if ($account['as_uid'] == $mybb->user['uid']) {

Similar to above, insert this beneath it to hide the account ids desired, replacing the (x,y) in the array with the groups you do not wish to show, or replacing the whole array with the desired group id number:
if (is_member(array(x,y), $account['uid'])) continue;