Holiday Notice – Support Unavailable on April 18 and April 21
We just wanted to let you know that our support team will be offline on Friday, April 18th (Good Friday) and Monday, April 21st (Easter Monday) due to the holidays.
We'll be back on Tuesday, ready to assist you!
In the meantime, if you need any help, feel free to:
-
Use the support widget in the bottom right corner on our websites (Amelia and wpDataTables) — our latest AI-powered assistant is there 24/7 to help with basic and intermediate questions,
-
Browse our detailed documentation (Amelia, wpDataTables)
-
Explore helpful articles,
-
Or check out our YouTube channels for video guides!
Amelia YouTube Channel
wpDataTables YouTube Channel
Thank you for your understanding, and we wish you a wonderful holiday weekend!
Hello,
I have assigned individual personnel numbers to my users. Now I would like to create a table (e.g. vacation plan) that recognizes the personnel number of the logged-in user and filters the table based on this condition. The user should only see the line that contains data for their personnel number. Personnel number = pnr,
Example: Personnel number = tt-060
SELECT Urlaubsplan_2024.`pnr`,
Urlaubsplan_2024.`name`,
Urlaubsplan_2024.`2024-01-01`,
Urlaubsplan_2024.`2024-01-02`,
Urlaubsplan_2024.`2024-01-03`,
Urlaubsplan_2024.`2024-01-04`,
Urlaubsplan_2024.`2024-01-05`,
…
FROM Urlaubsplan_2024, wp_Stammdaten
WHERE 1=1
AND wp_Stammdaten.`pnr` = 'tt-060'
Hi Alexander,
Apology for the late reply.
I am sorry to disappoint you, but we don't have an easy built-in solution to filter a table like this, because we do not have a placeholder available for filtering that can take your custom "personnel number" field, for example, if you added it somehow to the User's MetaData in your WordPress Database.
You can check all our currently available Dynamic Placeholders here, which can be used from the 'currently logged User' for easy filtering solutions.
For example, when it comes to the "Currently logged user" placeholders, we have these :
So, if you had a Field that stores the currently logged username, for example - you might add this in your SQL Query on the "WHERE" statement like :
SELECT Column A,
Column B
... ( other Columns) ...
FROM TableName
WHERE ColumnName = '%CURRENT_USER_LOGIN%'
This way, if you had a Column in your Table that stores each User's UserName - the Table would filter the rows to only show the ones which match the currently logged username.
Can you tell me, do you have the 'personnel number' somehow linked to the WP User's MetaData so that each User, when they log in, this personnel number is linked to them?
If so, you can only try a custom solution.
You could 'group' users with Custom user roles ( you can add Custom Roles via a Membership Plugin or User Role Editor Plugin), and assign the appropriate 'personnel number' as a Custom Role to them - then try filtering like that.
Please note, custom work is not covered by our Support, we can only try to get you started with a custom idea.
Here is an example we made where you can use a Custom User Role to filter the Data in the SQL Table.
On this example, we use the default Roles like Administrator, Subscriber, Editor and so on - but you can use the same 'principle'/logic, just need to modify it for your specific custom User Roles for filtering.
If the dependency is a user role, for example, we could make it work.
If I have this table:
This is a manual table which has manually entered IDs from wp_users and roles from wp_usermeta:
So, then I go to create an SQL query based table which will display entries based on user roles using this query:
When I'm logged in with user ID = 1, I see this:
When I'm logged in with user ID = 4, I see the same thing. And when I'm logged in as one of the subscribers, I can only see the rows where role = subscriber:
The only difference is that as subscriber I don't have access to back-end, so this confirms it is working on both front and back.
So, we're only left with hiding unnecessary columns, adding names, and so on.
I hope this helps.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables