• Hi Pete,

    (I’m not an IT guy in any way shape or form – just an everyday school teacher)

    I have a parent table called students and I have added a wp_username_id column in it. I’ve uploaded all my wp users’ first name, last name, ID and user_login into it and made a data project page with the wp_username_id=$$USER$$ in the where clause (I added all the user_login data in my wp_username_id column). I’ve added the shortcode to a page and now when a user logs in, they can only see their own row; that’s perfect as it gives me a basis to create a lesson-by-lesson report for parents to see when they log in as their child.

    Now, my question is:

    If my student table is a parent table to, say a classroom table or lesson report table or exam results table or subjects taught table (or anything like that), and I make new data projects pages to view (only) each of those tables in a 1:n project (separate pages), will adding wp_username_id=$$USER$$ to each pages’ WHERE clause do the same thing and only allow the user to view their own data?

    That way, I can create a student timetable, personal details, courses studying, lesson-by-lesson report and so on. The list can go on.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi. I am not Peter, obviously, but perhaps I can help.

    A description of the table columns would really help to offer an answer. Please provide a diagram of the tables. If you aren’t sure what a data model is, run a web search on “Data Modelling for Beginners”. There are several articles that will give you the insight you need.

    With that under your belt, please provide the “data model” with the “primary key” and “foreign keys” for each table. Then we can help you more.

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Mushfiqur,

    Your question:
    If my student table is a parent table to, say a classroom table or lesson report table or exam results table or subjects taught table (or anything like that), and I make new data projects pages to view (only) each of those tables in a 1:n project (separate pages), will adding wp_username_id=$$USER$$ to each pages’ WHERE clause do the same thing and only allow the user to view their own data?

    YES!! That is correct. You just need to make sure that every student has a WordPress account on your server, and you need to save the user name or id with the student record. After that you use the $$USER$$ or $$USERID$$ in your where clause, which prevents users from seeing each others data.

    Does this help?

    @mophilly Thank you for assistance!!

    Best regards,
    Peter

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘$$USER$$ and how many times to use it’ is closed to new replies.