Add custom profile fields to 'inactive users' list

Post Reply
User avatar
hiccup
Site Admin
Posts: 21
Joined: Sat Aug 01, 2015 8:44 pm

Add custom profile fields to 'inactive users' list

Post by hiccup » Fri Oct 02, 2015 10:33 pm

Add custom profile fields to 'inactive users' list in Admin Panel
tested on phpBB 3.1.6
custom-field-in-inactive-list.png
custom-field-in-inactive-list.png (47.4 KiB) Viewed 3367 times

https://www.phpbb.com/community/viewtop ... &t=1722745
References:
https://www.phpbb.com/community/viewtop ... &t=2159973
https://www.phpbb.com/community/viewtop ... 1&t=655245

1) Go to includes/functions_admin.php and find:

Code: php Select all

$sql = 'SELECT *
      FROM ' . USERS_TABLE . '
      WHERE user_type = ' . USER_INACTIVE .
      (($limit_days) ? " AND user_inactive_time >= $limit_days" : '') . "
      ORDER BY $sort_by";
   $result = $db->sql_query_limit($sql, $limit, $offset);
Replace with:

Code: php Select all

$sql = 'SELECT u.* , pfd.pf_reason
          FROM ' . USERS_TABLE . ' u
          INNER JOIN ' . PROFILE_FIELDS_DATA_TABLE . ' pfd ON pfd.user_id = u.user_id         WHERE user_type = ' . USER_INACTIVE .
          (($limit_days) ? " AND user_inactive_time >= $limit_days" : '') . "
          ORDER BY $sort_by";
       $result = $db->sql_query_limit($sql, $limit, $offset);
Remember to change 'reason' to the name of YOUR custom profile field name.

2) Go to includes/acp/acp_inactive.php and find:

Code: php Select all

'U_SEARCH_USER'   => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&sr=posts") : '',
On a line below, add

Code: php Select all

'ANSWER'      => $row['pf_reason'],
Remember to change 'reason' to the name of YOUR custom profile field name.

3) Go to adm/style/acp_inactive.html and find:

Code: html Select all

<th>{L_USERNAME}</th>
And add the following below:

Code: html Select all

<th>{L_ANSWER}</th>
Then, in the same file find:

Code: html Select all

<td style="vertical-align: top;">
         {inactive.USERNAME_FULL}
         <!-- IF inactive.POSTS --><br />{L_POSTS}: <strong>{inactive.POSTS}</strong> [<a href="{inactive.U_SEARCH_USER}">{L_SEARCH_USER_POSTS}</a>]<!-- ENDIF -->
      </td>
And add below the following:

Code: html Select all

<td style="vertical-align: top;">{inactive.ANSWER}</td>
4) Go to language/en/common.php and find

Code: php Select all

'USERNAME'            => 'Username',
And add below:

Code: php Select all

'ANSWER'                 => 'Answer:',
Save and / or upload all files. Then, log into ACP, and on General, click to Purge the Cache (last item on the list), and click Run Now. If necessary, hit ctrl+F5 afterwards. Now, navigate to Inactive Members list, and you should see the contents of your custom profile field listed there.

Post Reply