// Set user ID for current user \OC_User::setUserId('john.doe'); // Retrieve the user ID echo \OC_User::getUser()->getUID(); // Output: "john.doe"
// Set user ID for a different user \OC_User::setUserId('jane.smith', 'admin'); // Retrieve the user ID for the different user $user = \OC_User::getManager()->get('jane.smith'); echo $user->getUID(); // Output: "jane.smith"In this example, we set the user ID for a different user ("jane.smith") using the setUserId function and specifying the username of the user who has permission to do so ("admin"). We then retrieve the user object for the different user using the getManager function and get the user ID using the getUID function. Package library: ownCloud Core