diff --git a/OrcidProfilePlugin.inc.php b/OrcidProfilePlugin.inc.php index ce2f5ff7..3c690821 100644 --- a/OrcidProfilePlugin.inc.php +++ b/OrcidProfilePlugin.inc.php @@ -385,7 +385,17 @@ function collectUserOrcidId($hookName, $params) { $user =& $params[1]; $form->readUserVars(array('orcid')); - $user->setOrcid($form->getData('orcid')); + $orcid = $form->getData('orcid'); + $username = $form->getData('username'); + $userDao = DAORegistry::getDAO('UserDAO'); + + // On shutdown, persist the ORCID to the new user account. (https://github.com/pkp/pkp-lib/issues/4601) + register_shutdown_function(function() use ($orcid, $username, $userDao) { + $user = $userDao->getByUsername($username); + $user->setOrcid($orcid); + $userDao->updateObject($user); + }); + return false; }