| 1 |
<?php |
<?php |
| 2 |
// $Id: user.api.php,v 1.14 2009/10/10 16:48:39 webchick Exp $ |
// $Id: user.api.php,v 1.15 2009/11/01 21:26:44 webchick Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 314 |
* |
* |
| 315 |
* @param $account |
* @param $account |
| 316 |
* The user object on which the operation is being performed. |
* The user object on which the operation is being performed. |
| 317 |
|
* @param $build_mode |
| 318 |
|
* Build mode, e.g. 'full'. |
| 319 |
*/ |
*/ |
| 320 |
function hook_user_view($account) { |
function hook_user_view($account, $build_mode) { |
| 321 |
if (user_access('create blog content', $account)) { |
if (user_access('create blog content', $account)) { |
| 322 |
$account->content['summary']['blog'] = array( |
$account->content['summary']['blog'] = array( |
| 323 |
'#type' => 'user_profile_item', |
'#type' => 'user_profile_item', |
| 329 |
} |
} |
| 330 |
|
|
| 331 |
/** |
/** |
| 332 |
|
* The user was built; the module may modify the structured content. |
| 333 |
|
* |
| 334 |
|
* This hook is called after the content has been assembled in a structured array |
| 335 |
|
* and may be used for doing processing which requires that the complete user |
| 336 |
|
* content structure has been built. |
| 337 |
|
* |
| 338 |
|
* If the module wishes to act on the rendered HTML of the user rather than the |
| 339 |
|
* structured content array, it may use this hook to add a #post_render callback. |
| 340 |
|
* Alternatively, it could also implement hook_preprocess_user_profile(). See |
| 341 |
|
* drupal_render() and theme() documentation respectively for details. |
| 342 |
|
* |
| 343 |
|
* @param $build |
| 344 |
|
* A renderable array representing the user. |
| 345 |
|
* |
| 346 |
|
* @see user_build() |
| 347 |
|
*/ |
| 348 |
|
function hook_user_build_alter($build) { |
| 349 |
|
// Check for the existence of a field added by another module. |
| 350 |
|
if (isset($build['an_additional_field'])) { |
| 351 |
|
// Change its weight. |
| 352 |
|
$build['an_additional_field']['#weight'] = -10; |
| 353 |
|
} |
| 354 |
|
|
| 355 |
|
// Add a #post_render callback to act on the rendered HTML of the user. |
| 356 |
|
$build['#post_render'][] = 'my_module_user_post_render'; |
| 357 |
|
} |
| 358 |
|
|
| 359 |
|
/** |
| 360 |
* Inform other modules that a user role has been added. |
* Inform other modules that a user role has been added. |
| 361 |
* |
* |
| 362 |
* Modules implementing this hook can act on the user role object when saved to |
* Modules implementing this hook can act on the user role object when saved to |