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::getGroupNames
(REDCap >= 5.5.0)
REDCap::getGroupNames — Returns a list of group names (or unique group names) for all data access groups defined in the current project
Description
mixed REDCap::getGroupNames ( [ bool $unique_names = FALSE [, int $group_id = NULL ]] )
Returns a list of group names (or unique group names) for all data access groups defined in the current project. If $group_id is specified for a single data access group, it will return only the unique group name for that data access group.
Parameters
unique_names
Set this to TRUE to return the unique group names for the data access groups, else it will return the normal group names (i.e. group labels). By default, FALSE is used.
group_id
Group_id of a single data access group defined in the current project. If provided, it will return the group name (as a string) for only that data access group. By default, NULL is used, in which it will return an array of all unique group names in the current project. If group_id is invalid, returns FALSE.
Return Values
Returns array of group names with their corresponding group_id's as array keys. Returns FALSE if no data access groups exist for the current project. The groups are ordered in the order in which they appear in the project.
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 shows how to simply display the names of all data access groups (DAGs) in a project.
// Get all data access groups
$groups = REDCap::getGroupNames(false);

// Check if any DAGs exist in the project
if (empty($groups)) exit("Project does NOT contain any data access groups.");

// Print out the names of all DAGs
print "Groups: ";
foreach ($groups as $group_name) {
    // Print this DAG name
    print $group_name . ",\n";
}
Example #2:
This example illustrates how to obtain the unique group name for a single data access group using a group_id, as well as check if a group_id is valid for the current project.
// Manually set the group_id for a single data access group
$group_id = 52;

// Get the unique group name for the DAG
$unique_group_name = REDCap::getGroupNames(true, $group_id);

// Check if group_id was valid (if so, will have returned FALSE)
if ($unique_group_name === false) {
    // Group_id is not valid
    print "Group_id $group_id is not a valid group_id for this project.";
} else {
    // Display the unique group name
    print "The unique group name for group_id $group_id is \"$unique_group_name\".";
}
REDCap 14.9.1 - © 2024 Vanderbilt University