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::allowProjects
(REDCap >= 5.5.0)
REDCap::allowProjects — Limit a plugin's use only to specific REDCap projects
Description
bool REDCap::allowProjects ( mixed $project_ids )
Limit a plugin's use only to specific REDCap projects, in which the plugin will only function for the projects 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 allowProjects(), which will still continue to work if already used. The method REDCap::allowProjects() operates exactly the same as the older allowProjects() function.
Parameters
project_ids
A list of project_id's for the REDCap projects for which this plugin will function. Either an array of project_id's or a comma-delimited list of project_id's (i.e. each project_id is a separate argument/parameter).
Return Values
TRUE is returned if the current project is in the list of allowable projects that can use this plugin. If not or if the "pid" parameter is not found in the query string of the plugin URL, the plugin script will terminate right after displaying an HTML error on the page.
Restrictions
This method can ONLY be used in a project context (i.e. when "pid" parameter is in the query string of the plugin URL) or else a fatal error is produced.
Examples
Example #1:
This example demonstrates how to limit the plugin's use to three specific projects by passing the project_id's as an array list.
// Limit this plugin only to projects with project_id 3, 12, and 45
$projects = array(3, 12, 45);
allowProjects($projects);
Example #2:
This example shows how to limit the plugin's use to two specific projects by passing the project_id's as separate arguments/parameters to the method.
// Limit this plugin only to projects with project_id 56 and 112
allowProjects(56, 112);
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