| Versions | |
|---|---|
| 7 | action_example_node_sticky_action($node, $context) |
Promote and set sticky flag action. This is the special action that has been customized using the configuration form.
$node A node object provided by the associated trigger.
$context Array with the following elements:
examples/
<?php
function action_example_node_sticky_action($node, $context) {
if (function_exists('dsm')) {
dsm($node, 'action_example_node_sticky_action is firing. Here is the $node');
dsm($context, 'action_example_node_sticky_action is firing. Here is the $context');
}
// Get the user configured for this special action.
$account = user_load_by_name($context['author']);
// Is the node created by this user? then promote and set as sticky.
if ($account->uid == $node->uid) {
$node->promote = NODE_PROMOTED;
$node->sticky = NODE_STICKY;
watchdog('action', 'Set @type %title to sticky and promoted by special action for user %username.', array('@type' => node_type_get_name($node), '%title' => $node->title, '%username' => $account->name));
drupal_set_message(t('Set @type %title to sticky and promoted by special action for user %username.', array('@type' => node_type_get_name($node), '%title' => $node->title, '%username' => $account->name)));
}
}
?>