Jump to content

Absence List w/ Account Switcher Attached Accounts
   (0 reviews)

  • An absence list (using the "Away" status option via User CPs) that also displays attached accounts (using the "Account Switcher" plugin).

    Software: MyBB

Absence List w/ Account Switcher Attached Accounts

Tutorial Created By: isoldehn
Tutorial Permissions: Please do not re-post this tutorial else where, instead link someone to this thread.

- Additionally, you are NOT required to credit me if you use these codes on your board BUT I do wish for you to share this with those that ask about it if they ever do (share the knowledge, be kind).
Tutorial Needs: Overall, the ability to copy and paste.
- Knowledge Of MyBB Templates (you will be adding some)
- FTP/File Access To Web Space


Step One

We will begin by preparing all the templates and I will attempt to explain quickly the variables and additions I have made. You are welcome to modify these templates to suit your needs (customization, have at it).


Lets go ahead and open your Admin CP. From her navigate to Templates & Style --> Templates --> Global Templates. Add FOUR templates (Add Template option at the top).

  1. absences
  2. absences_entry
  3. absences_attached
  4. absences_empty


In the absences template you just created add in the following:

		<title>{$mybb->settings['bbname']} - Absences</title>
			.absences_attached {
				display: inline-block;
				padding-right: 20px;
			.absences_attached:last-child {
				padding-right: 0px;
		<table class="tborder" border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}">
				<td class="thead" colspan="4"><strong>Absences</strong></td>
				<td class="tcat" width="15%">Member</td>
				<td class="tcat" width="10%">From</td>
				<td class="tcat" width="10%">To</td>
				<td class="tcat" width="65%">Reason</td>


  • In style tags I have added special styling to how the attached accounts will display next to each other with a padding of 20px behind them EXCLUDING the last.
  • {$absentmembers} is the variable that will display all the information for members with absent statuses. This is important and however you plan to customize your template please ensure this variable is available or the list will not work (this variable will include templates absences_entry, absences_empty and absences_attached).


In the absences_entry template add the following:

	<td class="trow1">
		<a href="user-{$users['uid']}.html">{$users['username']}</a>
	<td class="trow1">
	<td class="trow1">
	<td class="trow1">
	<td class="trow2" colspan="4">
		<b>Additional Accounts:</b> {$absentattached}


  • <a href="member.php?action=profile&uid={$users['uid']}">{$users['username']}</a> will output a link generated to the users profile as well as their username! If you are using Search Engine Friendly URLs make the following change, if not ignore.
    • <a href="user-{$users['uid']}.html">{$users['username']}</a>
  • {$users['awaydate']} will output the day the user left (updated their away status).
  • {$users['returndate']} will output the day the user plans on returning, if the user left this blank it will state Unknown.
  • {$awayreason} will output the reason in which they gave as to why they are absent.
  • {$absentattached} will output all attached accounts to this user! It will also list what is in the absences_attached template.


In the absences_attached template add the following:

<div class="absences_attached">
	<a href="member.php?action=profile&amp;uid={$account['uid']}">{$account['username']}</a>


  • <a href="member.php?action=profile&uid={$account['uid']}">{$account['username']}</a> will output a link generated to the users profile as well as their username! If you are using Search Engine Friendly URLs make the following change, if not ignore.
    • <a href="user-{$account['uid']}.html">{$account['username']}</a> 


In the absences_empty template add the following:

	<td class="trow1" colspan="4" align="center">All members are currently here!</td>


  • All members are currently here! will output a message to display there are no users currently absent.


Our templates are all finished. Lets move on to step two and get the actual file rolling and in motion!


Step Two

We will create a new page in our web files area (generally this will be under public_html along with all of your other MyBB core files BUT if you have installed MyBB in another folder within public_html you will need to navigate there instead).


Name your new file absences.php open it up and add in the following. (We can then navigate to this page by going to /absences.php on the web page.)

// Original Away List Creator: mybbromania (https://mods.mybb.com/profile/13352)
// Updated Away List w/ Attached Accounts By: isoldehn (https://isoaff.com/)

define("IN_MYBB", 1);
define('THIS_SCRIPT', 'absences.php');

$templatelist = "absences,absences_entry,absences_attached,absences_empty";

require "./global.php";

add_breadcrumb("Absences", "absences.php");

$absentmembers = $absentattached = '';
$accounts = $eas->accountswitcher_cache;

$query = $db->query("
        SELECT *
        FROM ".TABLE_PREFIX."users
        WHERE ".TABLE_PREFIX."users.usergroup IN (#)
        ORDER BY username ASC
while($users = $db->fetch_array($query))    {
    if($users['away'] == '1')    {
        $users['profilelink'] = $users['uid'];
        $users['username'] = format_name($users['username'], $users['usergroup'], $users['displaygroup']);
        $users['awaydate'] = my_date($mybb->settings['dateformat'], $users['awaydate']);
        if($users['returndate'] == '') {
            $users['returndate'] = "$lang->unknown";
        else {
            $users['returndate'] = my_date($mybb->settings['dateformat'], strtotime($users['returndate']));
        $awayreason = $users['awayreason'];

        if (is_array($accounts)) {
            foreach ($accounts as $key => $account) {
                if ($account['as_uid'] == $users['uid']) {
                    $account['profilelink'] = get_profile_link($account['uid']);
                    $account['username'] = format_name($account['username'], $account['usergroup'], $account['displaygroup']);
                    eval("\$absentattached .= \"".$templates->get("absences_attached")."\";");

        eval("\$absentmembers .= \"".$templates->get("absences_entry")."\";");
        $absentattached = '';

if(!$absentmembers)  {
    eval("\$absentmembers .= \"".$templates->get("absences_empty")."\";");

eval("\$absences = \"".$templates->get("absences")."\";");


  • WHERE ".TABLE_PREFIX."users.usergroup IN (#) will need to have # removed and the usergroup ids added for all OOC/member/player accounts go.
    • For example groups 4, 3, 6, 8 are the player account groups on my board so I will use:
      WHERE ".TABLE_PREFIX."users.usergroup IN (4, 3, 8, 6)
    • If you need to find the usergroups id number you can do so in Admin CP --> Users & Groups --> Groups --> specific group --> the number at the end of said URL.

Edited by isoldehn
absentmember --> absentmembers (typo caused display issues)

Related Guides

  • c.widow

    Lonely, open or other threads listing! An automatic listing of threads with a specified thread prefix replied to within the last specified amount of days with less than a specified amount of replies.


User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.


Search In
  • More options...
Find results that contain...
Find results in...
  • Create New...

Important Information

By using this site, you agree to our Terms of Use, Guidelines and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.