Add custom profile fields to 'inactive users' list

This will be a how-to section for phpBB3-related customizations, optimizations, tweaks, mods, and hacks.
MKRD.info
Posts: 7
Joined: Sun Jun 12, 2011 9:42 am

Add custom profile fields to 'inactive users' list

Postby MKRD.info » Fri Aug 17, 2012 8:43 pm

I use a "custom profile field" as a spam-fighting technique, in conjunction with requiring Admin approvals of all accounts.

First, enable custom profile fields.

Then, add a custom profile field as a required field to the user registration form. I ask users for a reason for joining the forum, but this does not seem to the the best technique (as they can just type in asdf).


The biggest problem is that it used to take way too many clicks to filter out the spam. Previously, I had to navigate to Users and Groups, click on Inactive Members, open each member in a new tab, and for each member, open up the "Profile" sub-screen to see what they specified during their registration. Needless to say, this was an insane amount of work.

This is how to list the custom profile field response in the Inactive Members list (see attachment).
Add custom profile fields to 'inactive users' list.png
Add custom profile fields to 'inactive users' list
Add custom profile fields to 'inactive users' list.png (110.43 KiB) Viewed 12169 times


I will be expanding on the useful but no longer up-to-date article at https://www.phpbb.com/community/viewtopic.php?f=46&t=1722745

ffa wrote:I would like to use custom profile fields.


The post below will be an adaptation of the useful information before on how to include custom profile fields into the inactive members list.

References:
https://www.phpbb.com/community/viewtopic.php?f=71&t=2159973
https://www.phpbb.com/community/viewtopic.php?f=71&t=655245

I am not going to start a new thread because this is the message which will pop up in searches of this forum, first.

The information above needs to be modified for phpBB3 (3.0.8). The changes are:

* NOTE: Only use a proper editor such as Notepad++ to edit these files. Do not use Notepad or WordPad!*

* My custom profile field is called "reason" *

* Backup files and database before making any changes. You can edit these files by either downloading them with software such as FileZilla first and then editing on your computer, saving, and then uploading them back. You can also edit them right in FileZilla if you set Notepad++ to open .php and .html files by default. Or, you might be able to edit these files right in phpBB3 *

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

Code: 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: 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: 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: 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: Select all

   <th>{L_USERNAME}</th>


And add the following below:

Code: Select all

   <th>{L_ANSWER}</th>



Then, in the same file find:

Code: 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: Select all

      <td style="vertical-align: top;">{inactive.ANSWER}</td>



4) Go to language/en/common.php and find

Code: Select all

   'USERNAME'            => 'Username',


And add below:

Code: 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.

Note: if you do not see the value of custom profile field, remember to set the board settings correctly, and modify instructions above for the name of YOUR custom profile field!

Drop me a note if you are still having difficulty.

volmark
Posts: 1
Joined: Sat Aug 03, 2013 6:47 am

Re: Add custom profile fields to 'inactive users' list

Postby volmark » Sat Aug 03, 2013 2:56 pm

Generally say it is a bad idea to fetch one field at a time. We have 3 administrators in organisation and if one of us change custom field through ACP without changing corresponding lines in acp_inactive.html and acp_inactive.php the system will be crashed.
Is here the way to retrieve all customs fields for inactive users at once?


Return to “How-to's (phpBB3 related)”

Who is online

Users browsing this forum: No registered users and 1 guest