How do I add hidden columns that automatically stores created_by, created_datetime, last_updated_by, last_update_time ?
I don't want front end user see these columns, I can use variable to default these values, but don't know how to add invisible columns that store these values.
I'm not sure you'll be able to create all these columns. For "Created by" column, you would need to use Users see and edit only own data feature and select an integer column, where the plugin will store the User ID of a user that edited or added a new row to the table. No one other than the person who entered the data will be able to see that data.
That doesn't leave any space for "Last updated by" column, since the "Created by" will be overridden by the User ID that edits the row (only an admin could override that from back-end).
Same goes for created and last updated datetime. I can help you create a timestamp column, but it will be updated with every edit.
For example, I created a simple manual table:
wdt_ID column is being automatically generated, and is usually hidden, but I've displayed it here for explanation purposes.
When I created a table, and added the first row, I could then modify it. So, in order to set the Datetime column to be auto-populated, I had to open the table in the database. It is being stored as wp_wpdatatable_6, and you can see its database name in Editing tab in the settings above the table:
Then, in PHPMyAdmin, I opened the table, and ran the following query:
After that, again in the Editing tab, above the table, I changed the "ID column for editing" from "wdt_ID" to "datetime" (as you can see in the screenshot above). Then I disabled editing for "wdt_ID" in the column settings:
datetime column, being the "ID column for editing" automatically cannot be edited, but is automatically filled.
All columns can be hidden by simply toggling "Visible on front-end slider".
How do I add hidden columns that automatically stores created_by, created_datetime, last_updated_by, last_update_time ?
I don't want front end user see these columns, I can use variable to default these values, but don't know how to add invisible columns that store these values.
Hello Prer
Thank you for your purchase.
I'm not sure you'll be able to create all these columns. For "Created by" column, you would need to use Users see and edit only own data feature and select an integer column, where the plugin will store the User ID of a user that edited or added a new row to the table. No one other than the person who entered the data will be able to see that data.
That doesn't leave any space for "Last updated by" column, since the "Created by" will be overridden by the User ID that edits the row (only an admin could override that from back-end).
Same goes for created and last updated datetime. I can help you create a timestamp column, but it will be updated with every edit.
For example, I created a simple manual table:
wdt_ID column is being automatically generated, and is usually hidden, but I've displayed it here for explanation purposes.
When I created a table, and added the first row, I could then modify it. So, in order to set the Datetime column to be auto-populated, I had to open the table in the database. It is being stored as wp_wpdatatable_6, and you can see its database name in Editing tab in the settings above the table:
Then, in PHPMyAdmin, I opened the table, and ran the following query:
After that, again in the Editing tab, above the table, I changed the "ID column for editing" from "wdt_ID" to "datetime" (as you can see in the screenshot above). Then I disabled editing for "wdt_ID" in the column settings:
datetime column, being the "ID column for editing" automatically cannot be edited, but is automatically filled.
All columns can be hidden by simply toggling "Visible on front-end slider".
I hope this helps.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
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