A Data Project consists of one or more data administration and/or static pages. Use the role attribute to define which users should have access to a page. Use the $$USER$$ or $$USERID$$ environment variables to get access to the current user. $$USER$$ is related to database column wp_user.user_login. $$USERID$$ is related to database column wp_user.user_id.
In a student administration system for example, you might need a page to inform students about their personal results. Suppose student results are stored in table STUDENT_RESULTS which has a column STUDENT_NAME that holds the WordPress username of the student (or STUDENT_ID that holds the WordPress userid of the student).
You can restrict the information shown as follows:
- Give students a WordPress role (subscriber for example)
- Add the following WHERE clause to the student result page: STUDENT_NAME = $$USER$$ (or STUDENT_ID = $$USERID$$)
Students will see their own results only. If you have users who need to see all results, you might need a second student result page available to their role.
- You can set the default value of a table column to the WordPress username using the $$USER$$ environment variable:
Data Projects > Manage Table Options > select your table > set “Default value” to $$USER$$
- If you set the WHERE clause to “your_column_name=$$USER$$” and the default value for your_column_name to $$USER$$, users will be able to see and edit their personal data only.
- If you use the $$USERID$$ environment variable, make sure your column is numeric.