Group check in SQL query
-
I am trying to figure out a way of getting the group id in a mysql query.
Here is the scinario:
I have form data for different companies that i show on the front end in a table.
Each company had a group name / id
I am trying to write a query that i can integrate into another query to only show the form entries of the group that the site visitor is a member of.
A member of the group ATLAS when viewing the page can only see form entries created by others in his group.
Another member visits the page who is a member of the group PULSE and he will only see the form submissions from other PULSE members and nothing else.I dont really want to have to write an output table for every group.
Here is the query i run to show the table data from the database:global $wpdb; $result = $wpdb->get_results( "SELECT f_name, l_name, date, IF(score = max_score, 'PASSED','FAILED') AS score FROM wp_myplugin_data WHERE form_id=12");
I am thinking something like
IF currentuser_group = group_defined_in_usermeta
, but havent got a clue how to get it to work.
Any ideas how to write this into a mysql statement would be appreciated.
Thanks
- The topic ‘Group check in SQL query’ is closed to new replies.