Working …
This value you provided is not a number. Please try again.
This value you provided is not an integer. Please try again.
The value entered is not a valid Vanderbilt Medical Record Number (i.e. 4- to 9-digit number, excluding leading zeros). Please try again.
The value you provided must be within the suggested range
The value you provided is outside the suggested range
This value is admissible, but you may wish to double check it.
The value entered must be a time value in the following format HH:MM within the range 00:00-23:59 (e.g., 04:32 or 23:19).
This field must be a 5 or 9 digit U.S. ZIP Code (like 94043). Please re-enter it now.
This field must be a 10 digit U.S. phone number (like 415 555 1212). Please re-enter it now.
This field must be a valid email address (like joe@user.com). Please re-enter it now.
The value you provided could not be validated because it does not follow the expected format. Please try again.
Required format:
REDCap Logo
Plugins, Hooks, & External Modules
Developer methods for
Plugins, Hooks, & External Modules
Hook functions

REDCap Developer Tools:
Documentation for Plugins, Hooks, & External Modules

REDCap Version 14.9.1
REDCap::allowUsers
(REDCap >= 5.5.0)
REDCap::allowUsers — Limit a plugin's use only to specific REDCap users
Description
bool REDCap::allowUsers ( mixed $usernames )
Limit a plugin's use only to specific REDCap users, in which the plugin will only function for the users that are explicitly specified in the parameter of this method. It is recommended that this method be placed closer to the beginning of the plugin script (e.g., immediately after "require redcap_connect.php").

NOTE: As of version 5.5.0, this method supercedes the older global scope function allowUsers(), which will still continue to work if already used. The method REDCap::allowUsers() operates exactly the same as the older allowUsers() function.
Parameters
usernames
A list of usernames for the REDCap users for which this plugin will function. Either an array of usernames (each as a string) or a comma-delimited list of usernames (each as a string), in which each username is a separate argument/parameter.
Return Values
TRUE is returned if the current user's username is in the list of allowable usernames that can use this plugin. If not, the plugin script will terminate right after displaying an HTML error on the page. If authentication has been disabled for the plugin script, it will return FALSE.
Examples
Example #1:
This example demonstrates how to limit the plugin's use to three specific users by passing the usernames as an array list.
// Limit this plugin only to users 'taylorr4', 'minorbl', and 'harrispa'
$users = array('taylorr4', 'minorbl', 'harrispa');
allowUsers($users);
Example #2:
This example shows how to limit the plugin's use to two specific users by passing the usernames as separate arguments/parameters to the method.
// Limit this plugin only to users 'taylorr4' and 'harrispa'
allowUsers('taylorr4', 'harrispa');
Example #3:
This example illustrates how to utilize both REDCap::allowProjects() and REDCap::allowUsers() together to limit the plugin's use to two specific users in two specific projects
// Limit this plugin only to users 'taylorr4' and 'harrispa' in projects with project_id 56 and 112
allowProjects(56, 112);
allowUsers('taylorr4', 'harrispa');
REDCap 14.9.1 - © 2024 Vanderbilt University