Okay
  Public Ticket #2815599
UserID
Closed

Comments

  • Tierney started the conversation

    Who may concern,

    I have two roles in my website, which are admin and user. 

    then i want to create a table though wpdatatable in order to record user data (no admin data included). and i want each user can only see his own data, not others data.

    so I enabled the choice 'Users see and edit only own data' in the 'editing' portion. however, when I login as user, it's not what i expected. the first user (id = 2) will see the second row of the table (which record the second user's (id=3) data. that's because the admin's id=1. what I want is the first user (id=2) id =1 and see the first row of data in the table. Admin do not need to join this table.

  •  2,507
    Aleksandar replied

    Hello Tierney

    Thank you for your purchase.

    Please take a look at our documentation about this feature.

    You marked the wdt_ID column as the "User ID column" in the Editing tab above the table, and that's the row ID column. You need to add an integer column that will write the user's ID automatically when they add a new row.

    For existing rows, you need to manually add IDs of users in that column, before selecting it as the User ID column in the Editing tab.

    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

  • Tierney replied

    Hi Aleksandar,

    Thanks for your help.

    I have sucessfully done the userID part. But it seems has no relation about the name and email. Even user type their name and email address in registeration. 

  • [deleted] replied

    Hi Tierney 

    Could I kindly ask you to explain what do you mean by this "But it seems has no relation about the name and email. Even user type their name and email address in registeration. " and what you would like to achieve so we can get a better understanding and provide you with the best solution.

  • Tierney replied

    Hi Blaženka,

    Sorry for that.

    In the current stage, I am using "Ultimate Memebers" plugin to registier for new users. For new user they need to fill their details like "Name", "Email". And I also create a table in "WPDataTables" and add some attributes want to match these data. But I cannot find any relation between these. Do you have any ideas?

  • [deleted] replied

    Unfortunately we don't have a native integration with Ultimate Memebers plugin so we are not aware how to make this connection simply from wpDataTables. 

    If the dependency is a user role, for example, we could make it work.

    If I have this table:

    5458776907.png

    This is a manual table which has manually entered IDs from wp_users and roles from wp_usermeta:

    7855603551.png
    6462766399.png
    7686895681.png

    So, then I go to create an SQL query based table which will display entries based on user roles using this query:

    SELECT  new_table.id AS ID,        new_table.role AS Role,        new_table.product AS Product,        new_table.amount AS Amount
    FROM wp_wpdatatable_6 AS new_table
    JOIN wp_usermeta AS new_table_1
    ON new_table_1.user_id = %CURRENT_USER_ID%
    AND new_table_1.meta_value LIKE CONCAT('%', new_table.role, '%')
    

    When I'm logged in with user ID = 1, I see this:

    9999185249.png

    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:

    2907856651.png

    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.

    I hope this helps, do let me know if you need any further assistance.