We're Moving to a New Support Platform – Starting June 1st!

We’re excited to let you know that starting June 1st, we’ll be transitioning to a new support system that will be available directly on our product websites – Amelia, wpDataTables, and Report Builder. In fact, the new support platform is already live for Amelia and wpDataTables, and we encourage you to reach out to us there.

You'll always be able to reach us through a widget in the bottom right corner of each website, where you can ask questions, report issues, or simply get assistance.

While we still do not offer live support, a new advanced, AI-powered assistant, trained on our documentation, use cases, and real conversations with our team, is there to help with basic to intermediate questions in no time.

We're doing our best to make this transition smooth and hassle-free. After June 1st, this current support website will redirect you to the new "Contact Us" pages on our product sites.

Thanks for your continued support and trust – we’re excited to bring you an even better support experience!

Okay
  Public Ticket #2762884
Filter table on user role
Closed

Comments

  • jeffrey bernard started the conversation

    hello,

    How do I filter a table on user roles? I understand how to only show users their entries. My scenario is that I have users submitting data in a form, going to a MySQL table. I’m displaying the data back to the user and then want to show the data for an area to a manager. The managers email and user role is captured in the form, so I just need to know how to filter the table based on the role of the user viewing the table. 

  • [deleted] replied

    Hi Jeffrey

    Thank you for reaching out to us.

    If I understand your scenario correctly, you can add the placeholder %CURRENT_USER_ID% as the predefined filtering value in column settings of "User ID" column, and the table will automatically be filtered per the ID of the currently logged in user.

    I hope this helps, do let us know if there is anything else we can assist you with.


  • jeffrey bernard replied

    I need to filter by the user role on a table, not just the id. How can I filter by user role?

  • [deleted] replied

    If the dependency is a user role, for example, we could make it work like this:

    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.

  • jeffrey bernard replied

    Awesome! I will try this

  • [deleted] replied

    Do let us know if you need any further assistance, we are always happy to helpsmile.png 

    Have a wonderful day!