Created
September 26, 2011 21:59
-
-
Save greggles/1243531 to your computer and use it in GitHub Desktop.
1290624_example3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Provides an API function to load/tweak a user's name. | |
* Called by a module which has already checked permission and the validity of the $uid. | |
*/ | |
function example_module_usertweak($uid) { | |
global $user; | |
drupal_set_message(t('Thanks, @user, for tweaking this!', array('@user' => $user->name)); | |
// Save the original user. | |
$original_user = $user; | |
// Now load the current user and call a hook to allow modules to tweak it. | |
$user = user_load($uid); | |
$user = module_invoke_all('example_module_usertweak', $user); | |
user_save($user); | |
// Now switch back to the original user. | |
$user = $original_user; | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment