If you want to show only rows related to the currently logged-in user, there are two possible approaches depending on your table type:
You can use our built-in feature that lets users see and edit only their own data.
Just follow this guide: https://wpdatatables.com/documentation/front-end-editing/allowing-users-to-edit-only-their-own-data/
This will automatically filter the table for each user’s user ID
behind the scenes.
If your table is not editable (e.g., based on a Google Sheet, Excel, or similar), there’s a simple workaround using a placeholder:
user_id
ColumnFirst, edit your source (e.g., Google Sheet or Excel) and add a column named user_id
.
Populate this column so that each row is associated with the relevant user’s WordPress user ID.
In wpDataTables, edit the column settings for user_id
and:
Set the Filter type to Text
Add a Predefined filter value using the placeholder: %CURRENT_USER_ID%
Here’s how the table looks before any filter is applied — all rows are visible.
And now, when the pre-filter is active, and the Administrator is logged in (user ID = 1 in this example), only the rows matching that user ID are shown.
Need more details on placeholders?
Check out our documentation here:
Using Placeholders in wpDataTables
Even though the filter works, the user_id
filter input is still visible on the front-end. If someone manually clears or changes it, they could potentially see all rows.
To prevent this, we’ll hide the filter field using custom CSS.
Open the Customize tab in your table settings.
Use your browser's Inspect Element tool to find the correct selector.
Add custom CSS like this:
#table_1_5_filter_sections {
display: none;
}
Now, the user_id
filter is hidden on the front-end.
user_id
ColumnIf you'd also like to hide the user_id
column from front-end users:
Either disable it from the Column settings
Or use the Column list button from the backend to toggle visibility
That’s it! If you have any questions, feel free to reach out to our Support.