{"id":19713460,"url":"https://github.com/ctsit/extensible-redcap-hooks","last_synced_at":"2026-04-12T22:02:42.322Z","repository":{"id":79003716,"uuid":"78576370","full_name":"ctsit/extensible-redcap-hooks","owner":"ctsit","description":"Extensible REDCap Hooks","archived":false,"fork":false,"pushed_at":"2017-08-24T12:49:07.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-10T14:52:27.240Z","etag":null,"topics":["deprecated","redcap","redcap-hooks"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ctsit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-10T21:37:13.000Z","updated_at":"2020-06-17T15:48:09.000Z","dependencies_parsed_at":"2023-04-26T19:47:56.971Z","dependency_job_id":null,"html_url":"https://github.com/ctsit/extensible-redcap-hooks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctsit%2Fextensible-redcap-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctsit%2Fextensible-redcap-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctsit%2Fextensible-redcap-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctsit%2Fextensible-redcap-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctsit","download_url":"https://codeload.github.com/ctsit/extensible-redcap-hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241031939,"owners_count":19897386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deprecated","redcap","redcap-hooks"],"created_at":"2024-11-11T22:22:32.241Z","updated_at":"2026-04-12T22:02:42.311Z","avatar_url":"https://github.com/ctsit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Extensible REDCap Hooks - ARCHIVED\n\n**This repository has been archived and is no longer actively maintained.**\n\nThis project was archived as of October 1, 2025. The project for which it was written is now over. There's no funding to provide further maintenance for other projects. Please don't hesitate to use this code in accordance with the license; however, the authors are unable to offer any additional support.\n\n-----------\n\n\nREDCap supports only one hooks file, specified under REDCap Control Center \u003e\nGeneral Configuration \u003e REDCap Hooks. By using the `redcap_hooks.php` file in\nthis folder, you will essentially be able to use multiple hooks. Furthermore,\nhooks can be assigned to a specific project.\n\n\n## Installation\n\n 1. Move these files to your REDCap server, making note of the full path to the\n    `redcap_hooks.php` file.\n 2. Open your browser and go to your REDCap Control Center.\n 3. Click \"General Configuration\".\n 4. Under \"REDCap Hooks\", enter the full path to the `redcap_hooks.php` file.\n\n\n## Adding Hooks\n\nEssentially `redcap_hooks.php` adds a layer of indirection that allows for\nmultiple implementations per hook. Each hook-function in that file looks for\nactual hooks in other PHP files with the same name as the hook.\n\nFor example, if you wanted to add functionality when displaying a data entry\nform, the hook is called `redcap_data_entry_form`. So, you would create a\n`redcap_data_entry_form.php` file with your hook-function in it.\n\n\n## Writing Hook-functions\n\nTo avoid name collisions, each hook should be implemented as an [Anonymous\nFunction](http://php.net/manual/en/functions.anonymous.php)–introduced in PHP\n5.3–with the same parameters as the original hook.\n\nFor example, here is the entire contents of a `redcap_data_entry_form.php`\nfile:\n\n\t\u003c?php // redcap_data_entry_form.php\n\treturn function ($project_id, $record, $instrument, $event_id, $group_id) {\n\t\tprint '\u003cscript\u003ealert(\"REDCap Hook Alert!\");\u003c/script\u003e'\n\t};\n\n\n## Project-specific Hooks\n\nIf you wanted to have a hook enabled for a specific project, put your hook's\nfile under a folder named in the format `pid{$project_id}`, where\n`{$project_id}` is the project's REDCap ID.\n\nFor example, if you wanted the aforementioned Data Entry hook enabled only for\nProject #12, create `pid12/redcap_data_entry_form.php`.\n\n\n## Additional Hooks\n\nIf you have more than one hook, you can create a folder named after the hook\nand every PHP file under that folder will be assumed to be a hook file.\n\nFor example:\n\n  - `redcap_data_entry_form/print-disclaimer.php`\n  - `pid12/redcap_data_entry_form/00-alt-confirm-dialog-hook.php`\n  - `pid12/redcap_data_entry_form/01-other-hook.php`\n  - `pid12/redcap_data_entry_form/9-more-stuff.php`\n\n\n## Summary of File Naming Convention\n\nHooks are searched for in four places, all relative to the folder in which\n`redcap_hooks.php` resides:\n\n 1. Global hook: `$hook_name.php`\n 2. Additional global hooks: `$hook_name/*.php`\n 3. Project-specific hook: `pid{$project_id}/$hook_name.php`\n 4. Additional project-specific hooks: `pid{$project_id}/$hook_name/*.php`\n\n\"Global\" hooks are not specific to a project and will run for all projects.\n\n_Caveat:_ PHP's `__DIR__` is used, so take care if using symbolic links.\n\n\n## Supported Hooks\n\nEvery hook except `redcap_custom_verify_username` is supported.\n\nSince `redcap_custom_verify_username` has a non-void return type it has to be\nimplemented only if needed and directly in `redcap_hooks.php` as per the REDCap\ndocumentation.\n\n## Logging\n\nTo activate logging on a specific hook_function, add a `TRUE` as the third\nparameter of the call to `redcap_hooks_find` within that hook function.  E.g., turn\n\n    $hook_files = redcap_hooks_find('redcap_data_entry_form_top', $project_id);\n\ninto\n\n    $hook_files = redcap_hooks_find('redcap_data_entry_form_top', $project_id, TRUE);\n\nHook logging output will be written to `/tmp/hook_events.log` This can be changed by editing\nthe `redcap_hooks_find` function.\n\n\n## Contributors\n\n - Taeber Rapczak, University of Florida \u003ctaeber@ufl.edu\u003e\n - Philip Chase, University of Florida \u003cpbc@ufl.edu\u003e\n\nThank you to Andrew Martin (Stanford University) for his original work on\ncustom REDCap Hooks.\n\n\n## License\n\nCopyright 2017, University of Florida; licensed under the Apache License,\nVersion 2.0. See the [LICENSE](LICENSE) file for the full text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctsit%2Fextensible-redcap-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctsit%2Fextensible-redcap-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctsit%2Fextensible-redcap-hooks/lists"}