Skip to content

Latest commit

 

History

History

browse_limit_users_to_own_data

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Browse Screen: How to restrict users to view only their own records?

1. Add a PHP AS event

When saving the form, store the nuBuilder user id in a db column (e.g. user_id). To do so, place this code in the AS (PHP After Save) event:

if(nuHasNoRecordID()){
  $qry  = "UPDATE `your_table` SET `user_id` = ? WHERE your_table_pk = ?";
  nuRunQuery($qry,["#USER_ID#", "#RECORD_ID#"]); 
}

☛ Replace your_table, user_id and your_table_pk with your values.

2. Modify the Browse SQL

In the Browse SQL, add a WHERE clause like

WHERE user_id = '#USER_ID#'

If you want the globeadmin to view all records, add this WHERE clause.

WHERE user_id = '#USER_ID#' OR '#GLOBAL_ACCESS#' = '1'