Our Biggest Sale Is Here
Up to 70% Off
Get the Deal

How to let users see and edit only their own data in wpDataTables

Say your customers order printed signs through your site, and each of them should see and change only their own orders, never the orders of others. You don’t need a separate table per customer. One editable table with a user ID column does it: wpDataTables saves the ID of the logged-in user with every new row and shows each user only the rows that carry their ID.

How does editing only their own data work?

wpDataTables stores the ID of the user who adds a row in a user ID column, and then shows and lets each user edit only the rows with their ID. Users get the full set of actions, adding, viewing, editing and deleting, for their own rows, and they never see the rows of others. All you need is an editable table with an integer column for the user ID. In a manual table you add that column yourself, and in a table built on your own MySQL table you prepare an integer column for it.

How do I create a table with a user ID column?

Create a manual table and add an Integer column for the user ID next to the columns users fill in. For an orders table:

  1. Start the table. Go to wpDataTables → Create a Table, click Create a data table manually and name the table, for example My orders.
  2. Add the columns. Set up four columns:
Column Type Possible values
Order date Date
Product One-line selectbox Rectangle, Circle, Square
Comment Multi-line string
User ID Integer
  1. Create the table. Click the arrow on Create the table and choose Open in standard editor.

How do I turn on editing only their own data?

In the Editing tab, turn on Allow front-end editing and Limit editing to own data only, choose the user ID column and click Save Changes.

  1. Turn on editing. In the table editor, open the Editing tab and, under Allow editing, turn on Allow front-end editing.
  2. Limit users to their rows. Under Users see and edit only own data, turn on Limit editing to own data only.
  3. Choose the column. In User ID column, choose the User ID column. The list shows its database name, for example userid.
  4. Choose who can edit. In Editor roles, choose the roles of your users, for example Subscriber or Customer.
  5. Hide the user ID. Open the settings of the User ID column and turn off its visibility on the front end, because users don’t need to see it.
  6. Save the table. Click Save Changes.
The Editing tab of the My orders table with Allow front-end editing on, Limit editing to own data only on, userid as the User ID column and Subscriber as the editor role
Letting users edit only their own rows: (1) Allow editing, (2) Users see and edit only own data, (3) User ID column, (4) Editor roles.

Video: limiting editing to a user’s own rows and editing one as an Author.

Add the table to a page with its shortcode. Each logged-in user now sees an empty table, adds rows with the add button, and sees only those rows. When another user logs in, they don’t see them.

Always choose the Editor roles. If you leave them empty, visitors who aren’t logged in can edit the table too.

Which other options work with own data?

Two more options in the Editing tab change what users and admins see:

Option What it does
Show all rows in back-end Turn on Show all rows for this table in admin area to show all rows of all users in the WordPress admin, so you can manage every order. It also works for tables from the Gravity Forms integration.
Show all values from the foreign key table When a column is a foreign key, shows all values of the other table in the edit window, not only the values of the current user.

What should I remember about users’ own data?

Add an Integer user ID column to an editable table, turn on Limit editing to own data only, choose the column in User ID column, choose the editor roles and hide the column. wpDataTables then saves the user’s ID with every new row, and each user sees and edits only their own rows.

Wait, Before You Download!

To get your hands on wpDataTables Lite, please enter your email address below. We’ll send you a direct download link and keep you updated on existing features along with helpful tips and tricks!

By continuing, I accept Privacy Policy and T&C
Mail Box