Okay
  Public Ticket #1871077
Editing MySQL tables - Public and Private row data
Closed

Comments

  • alexkenley started the conversation

    Hi, I need to have some columns with existing data  viewable by all users as it is static data. Then related fields in the rows will be editable for only a users private data that they input from the front end. What is the best way to implement this? I have a Unique, auto increment, integer used as the ID for column editing.

    Screenshots attached, the first 12 columns from the left are static data that is the same for all users and will not be edited. the last 4 columns are where users will input private data.

    Would something like this work to show all data created by admin user then also only show current user data?

    SELECT * FROM `ISM_2018_Master`
    WHERE UserID = 0
    OR UserID = %CURRENT_USER_ID%

    Thanks for your assistance, it is a good plugin but I really need to get past this issue to be successful with my page/app.


    Cheers,

    Alex

  •  2,572
    Aleksandar replied

    Hello Alex.

    Thank you for your purchase.

    You can create editable table where users can see and edit only their own data, as described in our documentation. If you follow the tutorial there, you'll see that in order for the admin to view all users' data, you need to create an admin table and use this one as user-editable.

    You can set the Editor input type option of those static columns to None, so they won't appear in the edit modal. And only those 4 columns would still be editable.

    So, if ISM_Order column is the one that "picks up" the unique user ID, then this looks ok, and you just need to configure the current table, so users can only see and edit their own data.

    Please let me know if I understood what you meant correctly, and also if this helps.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia 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

  • alexkenley replied

    Hi Aleksander,

    Would users see same static rows but their updated columns of another table saves in another table - so all users can see all rows of 1st static table but with different 4 editable columns according to user base 2nd table?

  •  2,572
    Aleksandar replied

    Hello again Alex.

    If I understood you correctly, this is what you mean:

    Users have one table where they are able to see and edit only their own data, with 12 static columns that'd have Editor Input Type set to "None", so when they add new or modify existing content, they are only able to add 4 remaining columns.

    Then, they'd have a different table which would simply display all that data to all users. Correct?

    It might sound a little complicated, but please bear with me.

    The best way to go about this would be to create a table that contains the first 12 columns, and use them as a Foreign Key in the first (user-editable) table. Now, since you say the data is static, and doesn't change for any user, I believe you only need one row, but the table has to have 24 columns in the database (PHPMyAdmin), so you can use the Foreign Key option (each column has to have an ID, so the Store Value of foreign keys would know what to compare the Display Value to).

    Then, in the user-editable table you'd add relations to those first 12 (also 24 in total) columns from the previously created table, have a User ID auto-increment column, and add 4 more columns which will be editable by the user on front end.

    The Foreign key columns don't have editing enabled by default, so users will only be able to modify those 4 remaining columns.

    In the end, you need to create an admin table which would read all the data, and optionally disable editing for the whole table, so the users can only see what's in it.

    Please go through the documentation and examples on both Foreign Keys and User Editable tables to get a better understanding of what I'm saying if, by any chance I made it too complicated.

    Also, when viewing the documentation for User Editable tables, please look at the video, it explains how to view the content as admin as well.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia 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