Show rows related to the currently logged in user using the filterbyparams modification function

As discussed in other articles, it's possible to filter the table rows in order to show only those related to the currently logged in user. In some cases the most appropriate method is to use the modification function filterbyparam which is presented in this tutorial.

This function takes the following four arguments:

  • {param}: the parameter based on which the filtering will take place. The available options are:
    • {user_id}: The user id of the currently logged in user.
    • {user_name}: The user name of the currently logged in user.
    • {user_fullname}: The full name of the currently logged in user.
    • {user_groupids}: The group ids of the currently logged in user.
    .
  • 2 is the column that contains the user ids
  • 1 is the number of top row headers (excluded from the filtering process)
  • 0 is the number of bottom row headers (excluded from the filtering process)

Example arguments:

{user_id},2,1,0

Explanation:

  • {user_id} means that the filtering will be done using the user id of the currently logged in user.
  • 2 is the column that contains the user ids
  • 1 is the number of top row headers (excluded from the filtering process)
  • 0 is the number of bottom row headers (excluded from the filtering process)

Click here to the demo ruleset archive that contains the filterbyparams modification function. Don't forget to check the overwrite options when importing the archive.